Support Forum       Library Source       SourceForge Page       G3D Web Page     
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
G3D::CoordinateFrame Class Reference

A rigid body RT (rotation-translation) transformation. More...

Public Member Functions

 CoordinateFrame (const Any &any)
 
 CoordinateFrame ()
 Initializes to the identity coordinate frame.
 
 CoordinateFrame (const Point3 &_translation)
 
 CoordinateFrame (const Matrix3 &rotation, const Point3 &translation)
 
 CoordinateFrame (const Matrix3 &rotation)
 
 CoordinateFrame (const class UprightFrame &f)
 
 CoordinateFrame (class BinaryInput &b)
 
 CoordinateFrame (const CoordinateFrame &other)
 
 ~CoordinateFrame ()
 
void deserialize (class BinaryInput &b)
 
bool fuzzyEq (const CoordinateFrame &other) const
 
bool fuzzyIsIdentity () const
 
float getHeading () const
 Returns the heading of the lookVector as an angle in radians relative to the world -z axis.
 
void getXYZYPRDegrees (float &x, float &y, float &z, float &yaw, float &pitch, float &roll) const
 
void getXYZYPRRadians (float &x, float &y, float &z, float &yaw, float &pitch, float &roll) const
 
CoordinateFrame inverse () const
 Computes the inverse of this coordinate frame.
 
bool isIdentity () const
 
Vector3 leftVector () const
 If a viewer looks along the look vector, this is the viewer's "left".
 
CoordinateFrame lerp (const CoordinateFrame &other, float alpha) const
 Linearly interpolates between two coordinate frames, using Quat::slerp for the rotations.
 
void lookAt (const Point3 &target)
 
void lookAt (const Point3 &target, Vector3 up)
 
class Ray lookRay () const
 Returns the ray starting at the camera origin travelling in direction CoordinateFrame::lookVector.
 
Vector3 lookVector () const
 The direction this camera is looking (its negative z axis)
 
void moveTowards (const CoordinateFrame &goal, float maxTranslation, float maxRotation)
 Transform this coordinate frame towards goal, but not past it, goverened by maximum rotation and translations.
 
Vector3 normalToObjectSpace (const Vector3 &v) const
 
void normalToObjectSpace (const Array< Vector3 > &v, Array< Vector3 > &vout) const
 
Vector3 normalToWorldSpace (const Vector3 &v) const
 
void normalToWorldSpace (const Array< Vector3 > &v, Array< Vector3 > &vout) const
 
bool operator!= (const CoordinateFrame &other) const
 
CoordinateFrame operator* (const CoordinateFrame &other) const
 Compose: create the transformation that is other followed by this.
 
CoordinateFrame operator+ (const Vector3 &v) const
 
CoordinateFrame operator- (const Vector3 &v) const
 
bool operator== (const CoordinateFrame &other) const
 
Point3 pointToObjectSpace (const Point3 &v) const
 Transforms the point into object space.
 
void pointToObjectSpace (const Array< Point3 > &v, Array< Point3 > &vout) const
 
Point3 pointToWorldSpace (const Point3 &v) const
 Transforms the point into world space.
 
void pointToWorldSpace (const Array< Point3 > &v, Array< Point3 > &vout) const
 
Vector3 rightVector () const
 
void serialize (class BinaryOutput &b) const
 
Any toAny () const
 Converts the CFrame to an Any.
 
class Matrix4 toMatrix4 () const
 See also Matrix4::approxCoordinateFrame.
 
CoordinateFrame toObjectSpace (const CoordinateFrame &c) const
 Takes the coordinate frame into object space.
 
Vector4 toObjectSpace (const Vector4 &v) const
 
class Ray toObjectSpace (const Ray &r) const
 
class Box toObjectSpace (const AABox &b) const
 
class Box toObjectSpace (const Box &b) const
 
class Plane toObjectSpace (const Plane &p) const
 
class Sphere toObjectSpace (const Sphere &b) const
 
Triangle toObjectSpace (const Triangle &t) const
 
Vector4 toWorldSpace (const Vector4 &v) const
 
Ray toWorldSpace (const Ray &r) const
 
Frustum toWorldSpace (const Frustum &f) const
 
void toWorldSpace (const class AABox &b, class AABox &result) const
 
class Box toWorldSpace (const class AABox &b) const
 
class Box toWorldSpace (const class Box &b) const
 
class Cylinder toWorldSpace (const class Cylinder &b) const
 
class Capsule toWorldSpace (const class Capsule &b) const
 
class Plane toWorldSpace (const class Plane &p) const
 
class Sphere toWorldSpace (const class Sphere &b) const
 
class Triangle toWorldSpace (const class Triangle &t) const
 
std::string toXML () const
 Produces an XML serialization of this coordinate frame.
 
std::string toXYZYPRDegreesString () const
 
Vector3 upVector () const
 Up direction for this camera (its y axis).
 
Vector3 vectorToObjectSpace (const Vector3 &v) const
 Transforms the vector into object space (no translation).
 
void vectorToObjectSpace (const Array< Vector3 > &v, Array< Vector3 > &vout) const
 
Vector3 vectorToWorldSpace (const Vector3 &v) const
 Transforms the vector into world space (no translation).
 
void vectorToWorldSpace (const Array< Vector3 > &v, Array< Vector3 > &vout) const
 

Static Public Member Functions

static CoordinateFrame fromXYZYPRDegrees (float x, float y, float z, float yaw=0.0f, float pitch=0.0f, float roll=0.0f)
 Construct a coordinate frame from translation = (x,y,z) and rotations (in that order) about Y, object space X, object space Z.
 
static CoordinateFrame fromXYZYPRRadians (float x, float y, float z, float yaw=0.0f, float pitch=0.0f, float roll=0.0f)
 

Public Attributes

Matrix3 rotation
 Takes object space points to world space.
 
Point3 translation
 The origin of this coordinate frame in world space (or its parent's space, if nested).
 

Detailed Description

A rigid body RT (rotation-translation) transformation.

CoordinateFrame abstracts a 4x4 matrix that maps object space to world space:

v_world = C * v_object

CoordinateFrame::rotation is the upper 3x3 submatrix, CoordinateFrame::translation is the right 3x1 column. The 4th row is always [0 0 0 1], so it isn't stored. So you don't have to remember which way the multiplication and transformation work, it provides explicit toWorldSpace and toObjectSpace methods. Also, points, vectors (directions), and surface normals transform differently, so they have separate methods.

Some helper functions transform whole primitives like boxes in and out of object space.

Convert to Matrix4 using CoordinateFrame::toMatrix4. You can construct a CoordinateFrame from a Matrix4 using Matrix4::approxCoordinateFrame, however, because a Matrix4 is more general than a CoordinateFrame, some information may be lost.

See Also
G3D::UprightFrame, G3D::PhysicsFrame, G3D::Matrix4, G3D::Quat

Constructor & Destructor Documentation

G3D::CoordinateFrame::CoordinateFrame ( const Any any)
Parameters
anyMust be in one of the following forms:
  • CFrame((matrix3 expr), (Point3 expr))
  • CFrame::fromXYZYPRDegrees(#, #, #, #, #, #)
  • CFrame { rotation = (Matrix3 expr), translation = (Point3 expr) }
  • Point3( ... )
  • Matrix3( ... )
G3D::CoordinateFrame::CoordinateFrame ( )

Initializes to the identity coordinate frame.

Referenced by operator*(), operator+(), and operator-().

G3D::CoordinateFrame::CoordinateFrame ( const Point3 _translation)
inline
G3D::CoordinateFrame::CoordinateFrame ( const Matrix3 rotation,
const Point3 translation 
)
inline
G3D::CoordinateFrame::CoordinateFrame ( const Matrix3 rotation)
inline
G3D::CoordinateFrame::CoordinateFrame ( const class UprightFrame f)
G3D::CoordinateFrame::CoordinateFrame ( class BinaryInput b)
G3D::CoordinateFrame::CoordinateFrame ( const CoordinateFrame other)
inline
G3D::CoordinateFrame::~CoordinateFrame ( )
inline

Member Function Documentation

void G3D::CoordinateFrame::deserialize ( class BinaryInput b)
static CoordinateFrame G3D::CoordinateFrame::fromXYZYPRDegrees ( float  x,
float  y,
float  z,
float  yaw = 0.0f,
float  pitch = 0.0f,
float  roll = 0.0f 
)
static

Construct a coordinate frame from translation = (x,y,z) and rotations (in that order) about Y, object space X, object space Z.

Note that because object-space axes are used, these are not equivalent to Euler angles; they are known as Tait-Bryan rotations and are more convenient for intuitive positioning.

static CoordinateFrame G3D::CoordinateFrame::fromXYZYPRRadians ( float  x,
float  y,
float  z,
float  yaw = 0.0f,
float  pitch = 0.0f,
float  roll = 0.0f 
)
static
bool G3D::CoordinateFrame::fuzzyEq ( const CoordinateFrame other) const
bool G3D::CoordinateFrame::fuzzyIsIdentity ( ) const
float G3D::CoordinateFrame::getHeading ( ) const
inline

Returns the heading of the lookVector as an angle in radians relative to the world -z axis.

That is, a counter-clockwise heading where north (-z) is 0 and west (-x) is PI/2.

Note that the heading ignores the Y axis, so an inverted object has an inverted heading.

void G3D::CoordinateFrame::getXYZYPRDegrees ( float &  x,
float &  y,
float &  z,
float &  yaw,
float &  pitch,
float &  roll 
) const
void G3D::CoordinateFrame::getXYZYPRRadians ( float &  x,
float &  y,
float &  z,
float &  yaw,
float &  pitch,
float &  roll 
) const
CoordinateFrame G3D::CoordinateFrame::inverse ( ) const
inline

Computes the inverse of this coordinate frame.

Referenced by toObjectSpace().

bool G3D::CoordinateFrame::isIdentity ( ) const
Vector3 G3D::CoordinateFrame::leftVector ( ) const
inline

If a viewer looks along the look vector, this is the viewer's "left".

Useful for strafing motions and building alternative coordinate frames.

CoordinateFrame G3D::CoordinateFrame::lerp ( const CoordinateFrame other,
float  alpha 
) const

Linearly interpolates between two coordinate frames, using Quat::slerp for the rotations.

See Also
moveTowards
void G3D::CoordinateFrame::lookAt ( const Point3 target)
void G3D::CoordinateFrame::lookAt ( const Point3 target,
Vector3  up 
)
class Ray G3D::CoordinateFrame::lookRay ( ) const

Returns the ray starting at the camera origin travelling in direction CoordinateFrame::lookVector.

Vector3 G3D::CoordinateFrame::lookVector ( ) const
inline

The direction this camera is looking (its negative z axis)

Referenced by G3D::FirstPersonManipulator::lookVector(), and G3D::Light::position().

void G3D::CoordinateFrame::moveTowards ( const CoordinateFrame goal,
float  maxTranslation,
float  maxRotation 
)

Transform this coordinate frame towards goal, but not past it, goverened by maximum rotation and translations.

This is a useful alternative to lerp, especially if the goal is expected to change every transformation step so that constant start and end positions will not be available.

Parameters
goalStep from this towards goal
maxTranslationRateMeters
maxRotationRateRadians
See Also
lerp
Vector3 G3D::CoordinateFrame::normalToObjectSpace ( const Vector3 v) const
inline
void G3D::CoordinateFrame::normalToObjectSpace ( const Array< Vector3 > &  v,
Array< Vector3 > &  vout 
) const
Vector3 G3D::CoordinateFrame::normalToWorldSpace ( const Vector3 v) const
inline
void G3D::CoordinateFrame::normalToWorldSpace ( const Array< Vector3 > &  v,
Array< Vector3 > &  vout 
) const
bool G3D::CoordinateFrame::operator!= ( const CoordinateFrame other) const
inline
CoordinateFrame G3D::CoordinateFrame::operator* ( const CoordinateFrame other) const
inline

Compose: create the transformation that is other followed by this.

CoordinateFrame G3D::CoordinateFrame::operator+ ( const Vector3 v) const
inline
CoordinateFrame G3D::CoordinateFrame::operator- ( const Vector3 v) const
inline
bool G3D::CoordinateFrame::operator== ( const CoordinateFrame other) const
inline
Point3 G3D::CoordinateFrame::pointToObjectSpace ( const Point3 v) const
inline

Transforms the point into object space.

Assumes that the rotation matrix is orthonormal.

void G3D::CoordinateFrame::pointToObjectSpace ( const Array< Point3 > &  v,
Array< Point3 > &  vout 
) const
Point3 G3D::CoordinateFrame::pointToWorldSpace ( const Point3 v) const
inline

Transforms the point into world space.

Referenced by operator*().

void G3D::CoordinateFrame::pointToWorldSpace ( const Array< Point3 > &  v,
Array< Point3 > &  vout 
) const
Vector3 G3D::CoordinateFrame::rightVector ( ) const
inline
void G3D::CoordinateFrame::serialize ( class BinaryOutput b) const
Any G3D::CoordinateFrame::toAny ( ) const

Converts the CFrame to an Any.

class Matrix4 G3D::CoordinateFrame::toMatrix4 ( ) const
CoordinateFrame G3D::CoordinateFrame::toObjectSpace ( const CoordinateFrame c) const
inline

Takes the coordinate frame into object space.

this->inverse() * c

Vector4 G3D::CoordinateFrame::toObjectSpace ( const Vector4 v) const
inline
class Ray G3D::CoordinateFrame::toObjectSpace ( const Ray r) const
class Box G3D::CoordinateFrame::toObjectSpace ( const AABox b) const
class Box G3D::CoordinateFrame::toObjectSpace ( const Box b) const
class Plane G3D::CoordinateFrame::toObjectSpace ( const Plane p) const
class Sphere G3D::CoordinateFrame::toObjectSpace ( const Sphere b) const
Triangle G3D::CoordinateFrame::toObjectSpace ( const Triangle t) const
Vector4 G3D::CoordinateFrame::toWorldSpace ( const Vector4 v) const
inline

Referenced by toObjectSpace().

Ray G3D::CoordinateFrame::toWorldSpace ( const Ray r) const
Frustum G3D::CoordinateFrame::toWorldSpace ( const Frustum f) const
void G3D::CoordinateFrame::toWorldSpace ( const class AABox b,
class AABox result 
) const
class Box G3D::CoordinateFrame::toWorldSpace ( const class AABox b) const
class Box G3D::CoordinateFrame::toWorldSpace ( const class Box b) const
class Cylinder G3D::CoordinateFrame::toWorldSpace ( const class Cylinder b) const
class Capsule G3D::CoordinateFrame::toWorldSpace ( const class Capsule b) const
class Plane G3D::CoordinateFrame::toWorldSpace ( const class Plane p) const
class Sphere G3D::CoordinateFrame::toWorldSpace ( const class Sphere b) const
class Triangle G3D::CoordinateFrame::toWorldSpace ( const class Triangle t) const
std::string G3D::CoordinateFrame::toXML ( ) const

Produces an XML serialization of this coordinate frame.

Deprecated:
std::string G3D::CoordinateFrame::toXYZYPRDegreesString ( ) const
Vector3 G3D::CoordinateFrame::upVector ( ) const
inline

Up direction for this camera (its y axis).

Vector3 G3D::CoordinateFrame::vectorToObjectSpace ( const Vector3 v) const
inline

Transforms the vector into object space (no translation).

void G3D::CoordinateFrame::vectorToObjectSpace ( const Array< Vector3 > &  v,
Array< Vector3 > &  vout 
) const
Vector3 G3D::CoordinateFrame::vectorToWorldSpace ( const Vector3 v) const
inline

Transforms the vector into world space (no translation).

void G3D::CoordinateFrame::vectorToWorldSpace ( const Array< Vector3 > &  v,
Array< Vector3 > &  vout 
) const

Member Data Documentation

Matrix3 G3D::CoordinateFrame::rotation
Point3 G3D::CoordinateFrame::translation

documentation generated on Sat Jan 12 2013 22:49:54 using doxygen 1.8.2