Easy3D 2.5.3
Frame Class Reference

The Frame class represents a coordinate system, defined by a position and an orientation. More...

#include <easy3d/renderer/frame.h>

Inheritance diagram for Frame:
ManipulatedFrame ManipulatedCameraFrame

Public Member Functions

 Frame ()
 
virtual ~Frame ()
 
 Frame (const Frame &frame)
 
Frameoperator= (const Frame &frame)
 
World coordinates position and orientation
 Frame (const vec3 &position, const quat &orientation)
 
void setPosition (const vec3 &position)
 
void setPositionWithConstraint (vec3 &position)
 
void setOrientation (const quat &orientation)
 
void setOrientationWithConstraint (quat &orientation)
 
void setPositionAndOrientation (const vec3 &position, const quat &orientation)
 
void setPositionAndOrientationWithConstraint (vec3 &position, quat &orientation)
 
vec3 position () const
 
quat orientation () const
 
Local translation and rotation w/r reference Frame
void setTranslation (const vec3 &translation)
 
void setTranslationWithConstraint (vec3 &translation)
 
void setRotation (const quat &rotation)
 
void setRotationWithConstraint (quat &rotation)
 
void setTranslationAndRotation (const vec3 &translation, const quat &rotation)
 
void setTranslationAndRotationWithConstraint (vec3 &translation, quat &rotation)
 
vec3 translation () const
 
quat rotation () const
 
Frame hierarchy
const FramereferenceFrame () const
 
void setReferenceFrame (const Frame *const refFrame)
 
bool settingAsReferenceFrameWillCreateALoop (const Frame *const frame)
 
Frame modification
void translate (vec3 &t)
 
void translate (const vec3 &t)
 
void rotate (quat &q)
 
void rotate (const quat &q)
 
void rotateAroundPoint (quat &rotation, const vec3 &point)
 
void rotateAroundPoint (const quat &rotation, const vec3 &point)
 
void alignWithFrame (const Frame *const frame, bool move=false, float threshold=0.0f)
 
void projectOnLine (const vec3 &origin, const vec3 &direction)
 
Coordinate system transformation of 3D coordinates
vec3 coordinatesOf (const vec3 &src) const
 
vec3 inverseCoordinatesOf (const vec3 &src) const
 
vec3 localCoordinatesOf (const vec3 &src) const
 
vec3 localInverseCoordinatesOf (const vec3 &src) const
 
vec3 coordinatesOfIn (const vec3 &src, const Frame *const in) const
 
vec3 coordinatesOfFrom (const vec3 &src, const Frame *const from) const
 
Coordinate system transformation of vectors
vec3 transformOf (const vec3 &src) const
 
vec3 inverseTransformOf (const vec3 &src) const
 
vec3 localTransformOf (const vec3 &src) const
 
vec3 localInverseTransformOf (const vec3 &src) const
 
vec3 transformOfIn (const vec3 &src, const Frame *const in) const
 
vec3 transformOfFrom (const vec3 &src, const Frame *const from) const
 
Constraint on the displacement
Constraintconstraint () const
 
void setConstraint (Constraint *const constraint)
 
Associated matrices
mat4 matrix () const
 
mat4 worldMatrix () const
 
void setFromMatrix (const mat4 &m)
 

Inversion of the transformation

Signal modified
 
Frame inverse () const
 
Frame worldInverse () const
 

Detailed Description

The Frame class represents a coordinate system, defined by a position and an orientation.

A Frame is a 3D coordinate system, represented by a position() and an orientation(). The order of these transformations is important: the Frame is first translated and then rotated around the new translated origin.

A Frame is useful to define the position and orientation of a 3D rigid object, using its matrix() method, as shown below:

// Builds a Frame at position (0.5,0,0) and oriented such that its Y axis is
along the (1,1,1)
// direction. One could also have used setPosition() and setOrientation().
Frame fr(vec3(0.5,0,0), quat(vec3(0,1,0), vec3(1,1,1)));
glPushMatrix();
glMultMatrixd(fr.matrix());
// Draw your object here, in the local fr coordinate system.
glPopMatrix();
Frame()
Definition: frame.cpp:51
mat4 matrix() const
Definition: frame.cpp:141
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition: types.h:45
Quat< float > quat
A quaternion of float type.
Definition: types.h:86

Many functions are provided to transform a 3D point from one coordinate system (Frame) to an other: see coordinatesOf(), inverseCoordinatesOf(), coordinatesOfIn(), coordinatesOfFrom()...

You may also want to transform a 3D vector (such as a normal), which corresponds to applying only the rotational part of the frame transformation: see transformOf() and inverseTransformOf(). See the frameTransform example for an illustration.

The translation() and the rotation() that are encapsulated in a Frame can also be used to represent a rigid transformation of space. Such a transformation can also be interpreted as a change of coordinate system, and the coordinate system conversion functions actually allow you to use a Frame as a rigid transformation. Use inverseCoordinatesOf() (resp. coordinatesOf()) to apply the transformation (resp. its inverse). Note the inversion.

Hierarchy of Frames

The position and the orientation of a Frame are actually defined with respect to a referenceFrame(). The default referenceFrame() is the world coordinate system (represented by a NULL referenceFrame()). If you setReferenceFrame() to a different Frame, you must then differentiate:

A Frame is actually defined by its translation() with respect to its referenceFrame(), and then by a rotation() of the coordinate system around the new translated origin.

This terminology for local (translation() and rotation()) and global (position() and orientation()) definitions is used in all the methods' names and should be sufficient to prevent ambiguities. These notions are obviously identical when the referenceFrame() is NULL, i.e. when the Frame is defined in the world coordinate system (the one you are in at the beginning of the Viewer::draw() method, see the introduction page).

Frames can hence easily be organized in a tree hierarchy, which root is the world coordinate system. A loop in the hierarchy would result in an inconsistent (multiple) Frame definition. settingAsReferenceFrameWillCreateALoop() checks this and prevents setReferenceFrame() from creating such a loop.

This frame hierarchy is used in methods like coordinatesOfIn(), coordinatesOfFrom()... which allow coordinates (or vector) conversions from a Frame to any other one (including the world coordinate system).

However, one must note that this hierarchical representation is internal to the Frame classes. When the Frames represent OpenGL coordinates system, one should map this hierarchical representation to the OpenGL GL_MODELVIEW matrix stack. See the matrix() documentation for details.

Constraints

An interesting feature of Frames is that their displacements can be constrained. When a Constraint is attached to a Frame, it filters the input of translate() and rotate(), and only the resulting filtered motion is applied to the Frame. The default constraint() is NULL resulting in no filtering. Use setConstraint() to attach a Constraint to a frame.

Constraints are especially useful for the ManipulatedFrame instances, in order to forbid some mouse motions. See the constrainedFrame, constrainedCamera and luxo examples for an illustration.

Classical constraints are provided for convenience (see LocalConstraint, WorldConstraint and CameraConstraint) and new constraints can very easily be implemented.

Derived classes

The ManipulatedFrame class inherits Frame and implements a mouse motion conversion, so that a Frame (and hence an object) can be manipulated in the scene with the mouse.

Examples
Tutorial_204_Viewer_Qt, and Tutorial_206_CameraInterpolation.

Constructor & Destructor Documentation

◆ Frame() [1/3]

Frame ( )

Creates a default Frame.

Its position() is (0,0,0) and it has an identity orientation() quat. The referenceFrame() and the constraint() are NULL.

◆ ~Frame()

~Frame ( )
virtualdefault

Virtual destructor. Empty.

◆ Frame() [2/3]

Frame ( const Frame frame)

Copy constructor.

The translation() and rotation() as well as constraint() and referenceFrame() pointers are copied.

◆ Frame() [3/3]

Frame ( const vec3 position,
const quat orientation 
)

Creates a Frame with a position() and an orientation().

See the vec3 and quat documentations for convenient constructors and methods.

The Frame is defined in the world coordinate system (its referenceFrame() is NULL). It has a NULL associated constraint().

Member Function Documentation

◆ alignWithFrame()

void alignWithFrame ( const Frame *const  frame,
bool  move = false,
float  threshold = 0.0f 
)

Aligns the Frame with frame, so that two of their axis are parallel.

If one of the X, Y and Z axis of the Frame is almost parallel to any of the X, Y, or Z axis of frame, the Frame is rotated so that these two axis actually become parallel.

If, after this first rotation, two other axis are also almost parallel, a second alignment is performed. The two frames then have identical orientations, up to 90 degrees rotations.

threshold measures how close two axis must be to be considered parallel. It is compared with the absolute values of the dot product of the normalized axis. As a result, useful range is std::sqrt(2)/2 (systematic alignment) to 1 (no alignment).

When move is set to true, the Frame position() is also affected by the alignment. The new Frame's position() is such that the frame position (computed with coordinatesOf(), in the Frame coordinates system) does not change.

frame may be NULL and then represents the world coordinate system (same convention than for the referenceFrame()).

The rotation (and translation when move is true) applied to the Frame are filtered by the possible constraint().

Examples
Tutorial_203_Viewer_wxWidgets, and Tutorial_204_Viewer_Qt.

◆ constraint()

Constraint * constraint ( ) const
inline

Returns the current constraint applied to the Frame.

A NULL value (default) means that no Constraint is used to filter Frame translation and rotation. See the Constraint class documentation for details.

You may have to use a dynamic_cast to convert the result to a Constraint derived class.

◆ coordinatesOf()

vec3 coordinatesOf ( const vec3 src) const

Returns the Frame coordinates of a point src defined in the world coordinate system (converts from world to Frame).

inverseCoordinatesOf() performs the inverse convertion. transformOf() converts 3D vectors instead of 3D coordinates.

See the frameTransform example for an illustration.

◆ coordinatesOfFrom()

vec3 coordinatesOfFrom ( const vec3 src,
const Frame *const  from 
) const

Returns the Frame coordinates of the point whose position in the from coordinate system is src (converts from from to Frame).

coordinatesOfIn() performs the inverse transformation.

◆ coordinatesOfIn()

vec3 coordinatesOfIn ( const vec3 src,
const Frame *const  in 
) const

Returns the in coordinates of the point whose position in the Frame coordinate system is src (converts from Frame to in).

coordinatesOfFrom() performs the inverse transformation.

◆ inverse()

Frame inverse ( ) const

Returns a Frame representing the inverse of the Frame space transformation.

The rotation() of the new Frame is the quat::inverse() of the original rotation. Its translation() is the negated inverse rotated image of the original translation.

If a Frame is considered as a space rigid transformation (translation and rotation), the inverse() Frame performs the inverse transformation.

Only the local Frame transformation (i.e. defined with respect to the referenceFrame()) is inverted. Use worldInverse() for a global inverse.

The resulting Frame has the same referenceFrame() as the Frame and a NULL constraint().

Note
The scaling factor of the 4x4 matrix is 1.0.

◆ inverseCoordinatesOf()

vec3 inverseCoordinatesOf ( const vec3 src) const

Returns the world coordinates of the point whose position in the Frame coordinate system is src (converts from Frame to world).

coordinatesOf() performs the inverse convertion. Use inverseTransformOf() to transform 3D vectors instead of 3D coordinates.

◆ inverseTransformOf()

vec3 inverseTransformOf ( const vec3 src) const

Returns the world transform of the vector whose coordinates in the Frame coordinate system is src (converts vectors from Frame to world).

transformOf() performs the inverse transformation. Use inverseCoordinatesOf() to transform 3D coordinates instead of 3D vectors.

Examples
Tutorial_204_Viewer_Qt.

◆ localCoordinatesOf()

vec3 localCoordinatesOf ( const vec3 src) const

Returns the Frame coordinates of a point src defined in the referenceFrame() coordinate system (converts from referenceFrame() to Frame).

localInverseCoordinatesOf() performs the inverse convertion. See also localTransformOf().

◆ localInverseCoordinatesOf()

vec3 localInverseCoordinatesOf ( const vec3 src) const

Returns the referenceFrame() coordinates of a point src defined in the Frame coordinate system (converts from Frame to referenceFrame()).

localCoordinatesOf() performs the inverse convertion. See also localInverseTransformOf().

◆ localInverseTransformOf()

vec3 localInverseTransformOf ( const vec3 src) const

Returns the referenceFrame() transform of a vector src defined in the Frame coordinate system (converts vectors from Frame to referenceFrame()).

localTransformOf() performs the inverse transformation. See also localInverseCoordinatesOf().

◆ localTransformOf()

vec3 localTransformOf ( const vec3 src) const

Returns the Frame transform of a vector src defined in the referenceFrame() coordinate system (converts vectors from referenceFrame() to Frame).

localInverseTransformOf() performs the inverse transformation. See also localCoordinatesOf().

◆ matrix()

mat4 matrix ( ) const

Returns the 4x4 OpenGL transformation matrix represented by the Frame.

This method should be used in conjunction with glMultMatrixd() to modify the OpenGL modelview matrix from a Frame hierarchy. With this Frame hierarchy:

Frame* body = new Frame();
Frame* leftArm = new Frame();
Frame* rightArm = new Frame();
leftArm->setReferenceFrame(body);
rightArm->setReferenceFrame(body);

The associated OpenGL drawing code should look like:

void Viewer::draw()
{
glPushMatrix();
glMultMatrixd(body->matrix());
drawBody();
glPushMatrix();
glMultMatrixd(leftArm->matrix());
drawArm();
glPopMatrix();
glPushMatrix();
glMultMatrixd(rightArm->matrix());
drawArm();
glPopMatrix();
glPopMatrix();
}

Note the use of nested glPushMatrix() and glPopMatrix() blocks to represent the frame hierarchy: leftArm and rightArm are both correctly drawn with respect to the body coordinate system.

This matrix only represents the local Frame transformation (i.e. with respect to the referenceFrame()). Use worldMatrix() to get the full Frame transformation matrix (i.e. from the world to the Frame coordinate system). These two match when the referenceFrame() is NULL.

The result is only valid until the next call to matrix(), getMatrix(), worldMatrix() or getWorldMatrix(). Use it immediately (as above) or use getMatrix() instead.

Attention
The OpenGL format of the result is the transpose of the actual mathematical European representation (translation is on the last line instead of the last column).
Note
The scaling factor of the 4x4 matrix is 1.0.

◆ operator=()

Frame & operator= ( const Frame frame)

Equal operator.

The referenceFrame() and constraint() pointers are copied.

Attention
Signal and slot connections are not copied.

◆ orientation()

quat orientation ( ) const

Returns the orientation of the Frame, defined in the world coordinate system. See also position(), setOrientation() and rotation().

◆ position()

vec3 position ( ) const

Returns the position of the Frame, defined in the world coordinate system. See also orientation(), setPosition() and translation().

Examples
Tutorial_204_Viewer_Qt, and Tutorial_206_CameraInterpolation.

◆ projectOnLine()

void projectOnLine ( const vec3 origin,
const vec3 direction 
)

Translates the Frame so that its position() lies on the line defined by origin and direction (defined in the world coordinate system).

Simply uses an orthogonal projection. direction does not need to be normalized.

◆ referenceFrame()

const Frame * referenceFrame ( ) const
inline

Returns the reference Frame, in which coordinates system the Frame is defined.

The translation() and rotation() of the Frame are defined with respect to the referenceFrame() coordinate system. A NULL referenceFrame() (default value) means that the Frame is defined in the world coordinate system.

Use position() and orientation() to recursively convert values along the referenceFrame() chain and to get values expressed in the world coordinate system. The values match when the referenceFrame() is NULL.

Use setReferenceFrame() to set this value and create a Frame hierarchy. Convenient functions allow you to convert 3D coordinates from one Frame to an other: see coordinatesOf(), localCoordinatesOf(), coordinatesOfIn() and their inverse functions.

Vectors can also be converted using transformOf(), transformOfIn, localTransformOf() and their inverse functions.

◆ rotate() [1/2]

void rotate ( const quat q)

Rotates the Frame by q (defined in the Frame coordinate system): R = R*q.

The rotation actually applied to the Frame may differ from q since it can be filtered by the constraint(). Use rotate(quat&) or setRotationWithConstraint() to retrieve the filtered rotation value. Use setRotation() to directly rotate the Frame without taking the constraint() into account.

See also translate(const vec3&). Emits the modified() signal.

◆ rotate() [2/2]

void rotate ( quat q)

Same as rotate(const quat&) but q may be modified to satisfy the rotation constraint(). Its new value corresponds to the rotation that has actually been applied to the Frame.

◆ rotateAroundPoint() [1/2]

void rotateAroundPoint ( const quat rotation,
const vec3 point 
)

Same as rotateAroundPoint(), but with a const rotation quat. Note that the actual rotation may differ since it can be filtered by the constraint().

◆ rotateAroundPoint() [2/2]

void rotateAroundPoint ( quat rotation,
const vec3 point 
)

Makes the Frame rotate() by rotation around point.

point is defined in the world coordinate system, while the rotation axis is defined in the Frame coordinate system.

If the Frame has a constraint(), rotation is first constrained using Constraint::constrainRotation(). The translation which results from the filtered rotation around point is then computed and filtered using Constraint::constrainTranslation(). The new rotation value corresponds to the rotation that has actually been applied to the Frame.

Emits the modified() signal.

◆ rotation()

quat rotation ( ) const
inline

Returns the Frame rotation, defined with respect to the referenceFrame().

Use orientation() to get the result in the world coordinates. These two values are identical when the referenceFrame() is NULL (default).

See also setRotation() and setRotationWithConstraint().

Returns the current quat orientation. See setRotation().

◆ setConstraint()

void setConstraint ( Constraint *const  constraint)
inline

Sets the constraint() attached to the Frame.

A NULL value means no constraint. The previous constraint() should be deleted by the calling method if needed.

◆ setFromMatrix()

void setFromMatrix ( const mat4 m)

Sets the Frame from an OpenGL matrix representation (rotation in the upper left 3x3 matrix and translation on the last line).

Hence, if a code fragment looks like:

double m[16]={...};
glMultMatrixd(m);

It is equivalent to write:

Frame fr;
fr.setFromMatrix(m);
glMultMatrixd(fr.matrix());

Using this conversion, you can benefit from the powerful Frame transformation methods to translate points and vectors to and from the Frame coordinate system to any other Frame coordinate system (including the world coordinate system). See coordinatesOf() and transformOf().

Emits the modified() signal. See also matrix(), getMatrix() and quat::setFromRotationMatrix().

Attention
A Frame does not contain a scale factor. The possible scaling in m will not be converted into the Frame by this method.

◆ setOrientation()

void setOrientation ( const quat orientation)

Sets the orientation() of the Frame, defined in the world coordinate system. Emits the modified() signal.

Use setRotation() to define the local frame rotation (with respect to the referenceFrame()). The potential constraint() of the Frame is not taken into account, use setOrientationWithConstraint() instead.

◆ setOrientationWithConstraint()

void setOrientationWithConstraint ( quat orientation)

Same as setOrientation(), but orientation is modified so that the potential constraint() of the Frame is satisfied. See also setPositionWithConstraint() and setRotationWithConstraint().

◆ setPosition()

void setPosition ( const vec3 position)

Sets the position() of the Frame, defined in the world coordinate system. Emits the modified() signal.

Use setTranslation() to define the local frame translation (with respect to the referenceFrame()). The potential constraint() of the Frame is not taken into account, use setPositionWithConstraint() instead.

◆ setPositionAndOrientation()

void setPositionAndOrientation ( const vec3 position,
const quat orientation 
)

Same as successive calls to setPosition() and then setOrientation().

Only one modified() signal is emitted, which is convenient if this signal is connected to a Viewer::update() slot. See also setTranslationAndRotation() and setPositionAndOrientationWithConstraint().

◆ setPositionAndOrientationWithConstraint()

void setPositionAndOrientationWithConstraint ( vec3 position,
quat orientation 
)

Same as setPositionAndOrientation() but position and orientation are modified to satisfy the constraint. Emits the modified() signal.

◆ setPositionWithConstraint()

void setPositionWithConstraint ( vec3 position)

Same as setPosition(), but position is modified so that the potential constraint() of the Frame is satisfied. See also setOrientationWithConstraint() and setTranslationWithConstraint().

◆ setReferenceFrame()

void setReferenceFrame ( const Frame *const  refFrame)

Sets the referenceFrame() of the Frame.

The Frame translation() and rotation() are then defined in the referenceFrame() coordinate system. Use position() and orientation() to express these in the world coordinate system.

Emits the modified() signal if refFrame differs from the current referenceFrame().

Using this method, you can create a hierarchy of Frames. This hierarchy needs to be a tree, which root is the world coordinate system (i.e. a NULL referenceFrame()). A warning is printed and no action is performed if setting refFrame as the referenceFrame() would create a loop in the Frame hierarchy (see settingAsReferenceFrameWillCreateALoop()).

◆ setRotation()

void setRotation ( const quat rotation)
inline

Set the current rotation quat. See rotation() and the different quat constructors. Emits the modified() signal. See also setTranslation() and setRotationWithConstraint().

Sets the rotation() of the Frame, locally defined with respect to the referenceFrame(). Emits the modified() signal.

Use setOrientation() to define the world coordinates orientation(). The potential constraint() of the Frame is not taken into account, use setRotationWithConstraint() instead.

◆ setRotationWithConstraint()

void setRotationWithConstraint ( quat rotation)

Same as setRotation(), but rotation is modified so that the potential constraint() of the Frame is satisfied.

Emits the modified() signal. See also setTranslationWithConstraint() and setOrientationWithConstraint().

◆ settingAsReferenceFrameWillCreateALoop()

bool settingAsReferenceFrameWillCreateALoop ( const Frame *const  frame)

Returns true if setting frame as the Frame's referenceFrame() would create a loop in the Frame hierarchy.

◆ setTranslation()

void setTranslation ( const vec3 translation)
inline

Sets the translation() of the frame, locally defined with respect to the referenceFrame(). Emits the modified() signal.

Use setPosition() to define the world coordinates position(). Use setTranslationWithConstraint() to take into account the potential constraint() of the Frame.

◆ setTranslationAndRotation()

void setTranslationAndRotation ( const vec3 translation,
const quat rotation 
)

Same as successive calls to setTranslation() and then setRotation().

Only one modified() signal is emitted, which is convenient if this signal is connected to a Viewer::update() slot. See also setPositionAndOrientation() and setTranslationAndRotationWithConstraint().

◆ setTranslationAndRotationWithConstraint()

void setTranslationAndRotationWithConstraint ( vec3 translation,
quat rotation 
)

Same as setTranslationAndRotation(), but translation and orientation are modified to satisfy the constraint(). Emits the modified() signal.

◆ setTranslationWithConstraint()

void setTranslationWithConstraint ( vec3 translation)

Same as setTranslation(), but translation is modified so that the potential constraint() of the Frame is satisfied.

Emits the modified() signal. See also setRotationWithConstraint() and setPositionWithConstraint().

◆ transformOf()

vec3 transformOf ( const vec3 src) const

Returns the Frame transform of a vector src defined in the world coordinate system (converts vectors from world to Frame).

inverseTransformOf() performs the inverse transformation. coordinatesOf() converts 3D coordinates instead of 3D vectors (here only the rotational part of the transformation is taken into account).

See the frameTransform example for an illustration.

◆ transformOfFrom()

vec3 transformOfFrom ( const vec3 src,
const Frame *const  from 
) const

Returns the Frame transform of the vector whose coordinates in the from coordinate system is src (converts vectors from from to Frame).

transformOfIn() performs the inverse transformation.

◆ transformOfIn()

vec3 transformOfIn ( const vec3 src,
const Frame *const  in 
) const

Returns the in transform of the vector whose coordinates in the Frame coordinate system is src (converts vectors from Frame to in).

transformOfFrom() performs the inverse transformation.

◆ translate() [1/2]

void translate ( const vec3 t)

Translates the Frame of t (defined in the Frame coordinate system).

The translation actually applied to the Frame may differ from t since it can be filtered by the constraint(). Use translate(vec3&) or setTranslationWithConstraint() to retrieve the filtered translation value. Use setTranslation() to directly translate the Frame without taking the constraint() into account.

See also rotate(const quat&). Emits the modified() signal.

◆ translate() [2/2]

void translate ( vec3 t)

Same as translate(const vec3&) but t may be modified to satisfy the translation constraint(). Its new value corresponds to the translation that has actually been applied to the Frame.

Examples
Tutorial_204_Viewer_Qt.

◆ translation()

vec3 translation ( ) const
inline

Returns the Frame translation, defined with respect to the referenceFrame().

Use position() to get the result in the world coordinates. These two values are identical when the referenceFrame() is NULL (default).

See also setTranslation() and setTranslationWithConstraint().

◆ worldInverse()

Frame worldInverse ( ) const
inline

Returns the inverse() of the Frame world transformation.

The orientation() of the new Frame is the quat::inverse() of the original orientation. Its position() is the negated and inverse rotated image of the original position.

The result Frame has a NULL referenceFrame() and a NULL constraint().

Use inverse() for a local (i.e. with respect to referenceFrame()) transformation inverse.

◆ worldMatrix()

mat4 worldMatrix ( ) const

Returns the 4x4 OpenGL transformation matrix represented by the Frame.

This method should be used in conjunction with glMultMatrixd() to modify the OpenGL modelview matrix from a Frame:

// The modelview here corresponds to the world coordinate system.
Frame fr(pos, quat(from, to));
glPushMatrix();
glMultMatrixd(fr.worldMatrix());
// draw object in the fr coordinate system.
glPopMatrix();

This matrix represents the global Frame transformation: the entire referenceFrame() hierarchy is taken into account to define the Frame transformation from the world coordinate system. Use matrix() to get the local Frame transformation matrix (i.e. defined with respect to the referenceFrame()). These two match when the referenceFrame() is NULL.

The OpenGL format of the result is the transpose of the actual mathematical European representation (translation is on the last line instead of the last column).

Attention
The result is only valid until the next call to matrix(), getMatrix(), worldMatrix() or getWorldMatrix(). Use it immediately (as above) or use getWorldMatrix() instead.
Note
The scaling factor of the 4x4 matrix is 1.0.
Examples
Tutorial_207_RealCamera.

The documentation for this class was generated from the following files: