All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions
Eegeo::Camera::CameraHelpers Namespace Reference

Camera utility functions. More...

Functions

void CalculateLookAt (const dv3 &interestPointEcef, const v3 &interestBasisFoward, float pitchRadians, float distanceCameraToInterest, dv3 &out_cameraLocation, v3 &out_cameraDirection, v3 &out_cameraUp)
 calculate a coordinate frame for positioning and orienting a camera to look towards an interest point More...
 
void CalculateCameraOrientation (const v3 &viewDirection, const v3 &upAxis, m33 &out_cameraOrientation)
 create a rotation matrix suitable for orienting a camera More...
 
float GetAbsoluteBearingRadians (const dv3 &pointEcef, const v3 &headingDirection)
 calculate an absolute bearing in radians from an ECEF point and heading direction More...
 
v3 GetScreenPositionFromLatLong (const Eegeo::Space::LatLong &latLong, const RenderCamera &renderCamera)
 project a latitude and longitude coordinate in the 3D world to a screen coordinate More...
 
v3 GetScreenPositionFromLatLongAlt (const Eegeo::Space::LatLongAltitude &latLongAlt, const RenderCamera &renderCamera)
 project a latitude, longitude & altitude coordinate in the 3D world to a screen coordinate More...
 
v3 GetScreenPositionFromEcef (const dv3 &ecefPosition, const RenderCamera &renderCamera)
 project an ECEF coordinate in the 3D world to a screen coordinate More...
 
void GetScreenPickRay (const RenderCamera &renderCamera, float screenPixelX, float screenPixelY, dv3 &out_rayDirection)
 create a ray in ECEF coordinates passing through camera origin and a screen at pixel coordinates More...
 
bool TryGetScreenPickIntersectionWithEarthCentredSphere (const RenderCamera &renderCamera, float screenPixelX, float screenPixelY, double sphereRadius, dv3 &out_ecefIntersectionPoint)
 Attempt to find the intersection point of a sphere centred at ECEF origin, with a ray from camera origin and passing through a point defined in screenspace. More...
 
void EcefTangentBasisFromPointAndHeading (const dv3 &pointEcef, float absoluteHeadingDegrees, Space::EcefTangentBasis &out_basis)
 Create an Ecef tangent space coordinate frame from a point and a bearing angle. More...
 
v3 CameraRelativePoint (const dv3 &pointEcef, const dv3 &cameraOrigin)
 calculate the single-precision vector to translate from cameraOrigin to pointEcef More...
 
void GetAltitudeInterpolatedNearFar (float absoluteCameraAltitude, float approxTerrainAltitude, float approxTerrainAltitudeDelta, const double scalingFunctionAltitudeThreshold, float &out_nearDistance, float &out_farDistance)
 calculate a recommended near and far clipping plane distance based on camera altitude and height of terrain to ensure everything is within the frustum More...
 
Geometry::Ray ScreenPointToRay (const v2 &screenPoint, const v2 &screenDimensions, const m44 &inverseViewProjectionMatrix, const dv3 &viewOriginEcef)
 
dv3 ScreenPointToRayDirection (const v2 &screenPoint, const v2 &screenDimensions, const m44 &inverseViewProjectionMatrix)
 
v3 ClipCoordToScreenPoint (const v4 &clipCoord, const v2 &screenDimensions)
 
bool TryScreenProject (const dv3 &pointEcef, const dv3 &cameraOriginEcef, const m44 &viewProjectionMatrix, const v2 &screenDimensions, v3 &out_screenPoint)
 
v3 ScreenProjectWithDefaultHomogeneousW (const dv3 &pointEcef, const dv3 &cameraOriginEcef, const m44 &viewProjectionMatrix, const v2 &screenDimensions, const float defaultHomogeneousW)
 
float VerticalFieldOfViewFromProjection (const m44 &projectionMatrix)
 
float NearClipDistanceFromProjection (const m44 &projectionMatrix)
 
float FarClipDistanceFromProjection (const m44 &projectionMatrix)
 
CameraState BuildCameraStateFromRenderCamera (const RenderCamera &camera, const dv3 &cameraInterestPointEcef)
 

Detailed Description

Camera utility functions.

Function Documentation

void Eegeo::Camera::CameraHelpers::CalculateCameraOrientation ( const v3 &  viewDirection,
const v3 &  upAxis,
m33 &  out_cameraOrientation 
)

create a rotation matrix suitable for orienting a camera

Parameters
viewDirectionview direction of camera in ECEF space
upAxisup direction of camera in ECEF space.
out_cameraOrientation[out] resultant camera model-to-world rotation matrix
void Eegeo::Camera::CameraHelpers::CalculateLookAt ( const dv3 &  interestPointEcef,
const v3 &  interestBasisFoward,
float  pitchRadians,
float  distanceCameraToInterest,
dv3 &  out_cameraLocation,
v3 &  out_cameraDirection,
v3 &  out_cameraUp 
)

calculate a coordinate frame for positioning and orienting a camera to look towards an interest point

Parameters
interestPointEceflocation of camera interest point in ECEF coordinates
interestBasisFowarddirection vector defining the azimuth orientation of the camera direction
pitchRadianselevation angle in radians between the Earth tangent plane at interest point and the camera view direction
distanceCameraToInterestdesired distance in metres from camera origin to interest point
out_cameraLocation[out] Camera origin in ECEF coordinates
out_cameraDirection[out] Camera view direction in ECEF space
out_cameraUp[out] Camera up direction in ECEF space
v3 Eegeo::Camera::CameraHelpers::CameraRelativePoint ( const dv3 &  pointEcef,
const dv3 &  cameraOrigin 
)

calculate the single-precision vector to translate from cameraOrigin to pointEcef

Parameters
pointEcefpoint in ECEF coordinates
cameraOrigincamera origin location in ECEF coordinates
Returns
(pointEcef - cameraOrigin) as a single-precision vector
void Eegeo::Camera::CameraHelpers::EcefTangentBasisFromPointAndHeading ( const dv3 &  pointEcef,
float  absoluteHeadingDegrees,
Space::EcefTangentBasis &  out_basis 
)

Create an Ecef tangent space coordinate frame from a point and a bearing angle.

Parameters
pointEcefpoint in ECEF coordinates
absoluteHeadingDegreesbearing angle in degrees, clockwise from North
out_basis[out] resultant EcefTangentBasis located at pointEcef, and oriented to that out_basis.GetForward() points in the direction specified by bearing angle
float Eegeo::Camera::CameraHelpers::GetAbsoluteBearingRadians ( const dv3 &  pointEcef,
const v3 &  headingDirection 
)

calculate an absolute bearing in radians from an ECEF point and heading direction

Parameters
pointEcefpoint in ECEF coordinates
headingDirectiondirection vector in ECEF space defining an orientation at pointECEF. The heading is projected onto the Earth tangent plane at pointECEF. The bearing angle is the angle between the resultant direction, and a vector on the tangent plane pointing towards the North Pole
Returns
absolute bearing angle in radians, with 0=North, and increasing positive angles rotating clockwise through compass directions (North -> East -> South -> West)
void Eegeo::Camera::CameraHelpers::GetAltitudeInterpolatedNearFar ( float  absoluteCameraAltitude,
float  approxTerrainAltitude,
float  approxTerrainAltitudeDelta,
const double  scalingFunctionAltitudeThreshold,
float &  out_nearDistance,
float &  out_farDistance 
)

calculate a recommended near and far clipping plane distance based on camera altitude and height of terrain to ensure everything is within the frustum

Parameters
Thealtitude in meters of the camera
Theapproximate altitude of the highest terrain in the scene
Thedifference between the highest and lowest terrain in the scene
Altitudeat which the method for scaling the near/far bounds changes (Default 15000m)
out_nearDistance[out] resultant recommended Near value based on the provided altitudes
out_farDistance[out] resultant reecommended Far value based on the provided altitudes
void Eegeo::Camera::CameraHelpers::GetScreenPickRay ( const RenderCamera &  renderCamera,
float  screenPixelX,
float  screenPixelY,
dv3 &  out_rayDirection 
)

create a ray in ECEF coordinates passing through camera origin and a screen at pixel coordinates

Parameters
renderCameracamera object defining world, view and projection camera transforms
screenPixelXhorizonal screen coordinate in pixels
screenPixelYvertical screen coordinate in pixels
out_rayDirection[out] resultant ray direction. The ray origin is renderCamera.GetEcefLocation()
v3 Eegeo::Camera::CameraHelpers::GetScreenPositionFromEcef ( const dv3 &  ecefPosition,
const RenderCamera &  renderCamera 
)

project an ECEF coordinate in the 3D world to a screen coordinate

Parameters
TheECEF coordinate in the world to project to screen
TheRenderCamera used to display the world.
Returns
The projection of the ECEF position on the screen, where X and Y represent a viewport coordinate and Z represents the depth in the frustum.
v3 Eegeo::Camera::CameraHelpers::GetScreenPositionFromLatLong ( const Eegeo::Space::LatLong latLong,
const RenderCamera &  renderCamera 
)

project a latitude and longitude coordinate in the 3D world to a screen coordinate

Parameters
TheLatLong coordinate in the world to project to screen
TheRenderCamera used to display the world.
Returns
The projection of the LatLong on the screen, where X and Y represent a viewport coordinate and Z represents the depth in the frustum.
v3 Eegeo::Camera::CameraHelpers::GetScreenPositionFromLatLongAlt ( const Eegeo::Space::LatLongAltitude latLongAlt,
const RenderCamera &  renderCamera 
)

project a latitude, longitude & altitude coordinate in the 3D world to a screen coordinate

Parameters
TheLatLongAlt coordinate in the world to project to screen
TheRenderCamera used to display the world.
Returns
The projection of the LatLongAlt on the screen, where X and Y represent a viewport coordinate and Z represents the depth in the frustum.
bool Eegeo::Camera::CameraHelpers::TryGetScreenPickIntersectionWithEarthCentredSphere ( const RenderCamera &  renderCamera,
float  screenPixelX,
float  screenPixelY,
double  sphereRadius,
dv3 &  out_ecefIntersectionPoint 
)

Attempt to find the intersection point of a sphere centred at ECEF origin, with a ray from camera origin and passing through a point defined in screenspace.

Parameters
renderCameracamera object defining world, view and projection camera transforms
screenPixelXhorizonal screen coordinate in pixels
screenPixelYvertical screen coordinate in pixels
sphereRadiusradius of sphere in metres, typically Eegeo::Space::EarthConstants::Radius for the Earth
out_ecefIntersectionPoint[out] intersection point between ray and sphere, in ECEF space
Returns
true if ray and sphere intersect, false otherwise