Easy3D 2.6.1
|
The Frame class represents a coordinate system, defined by a position and an orientation. More...
#include <easy3d/renderer/frame.h>
Public Member Functions | |
Frame () | |
Default constructor. | |
virtual | ~Frame () |
Frame (const Frame &frame) | |
Copy constructor. | |
Frame & | operator= (const Frame &frame) |
Assignment operator. | |
World coordinates position and orientation | |
Frame (const vec3 &position, const quat &orientation) | |
Constructor with position and orientation. | |
void | setPosition (const vec3 &position) |
Sets the position of the Frame. | |
void | setPositionWithConstraint (vec3 &position) |
Sets the position of the Frame with constraint. | |
void | setOrientation (const quat &orientation) |
Sets the orientation of the Frame. | |
void | setOrientationWithConstraint (quat &orientation) |
Sets the orientation of the Frame with constraint. | |
void | setPositionAndOrientation (const vec3 &position, const quat &orientation) |
Sets the position and orientation of the Frame. | |
void | setPositionAndOrientationWithConstraint (vec3 &position, quat &orientation) |
Sets the position and orientation of the Frame with constraint. | |
vec3 | position () const |
Returns the position of the Frame. | |
quat | orientation () const |
Returns the orientation of the Frame. | |
Local translation and rotation w/r reference Frame | |
void | setTranslation (const vec3 &translation) |
Sets the translation of the Frame. | |
void | setTranslationWithConstraint (vec3 &translation) |
Sets the translation of the Frame with constraint. | |
void | setRotation (const quat &rotation) |
Sets the rotation of the Frame. | |
void | setRotationWithConstraint (quat &rotation) |
Sets the rotation of the Frame with constraint. | |
void | setTranslationAndRotation (const vec3 &translation, const quat &rotation) |
Sets the translation and rotation of the Frame. | |
void | setTranslationAndRotationWithConstraint (vec3 &translation, quat &rotation) |
Sets the translation and rotation of the Frame with constraint. | |
vec3 | translation () const |
Returns the translation of the Frame. | |
quat | rotation () const |
Returns the rotation of the Frame. | |
Frame hierarchy | |
const Frame * | referenceFrame () const |
Returns the reference Frame. | |
void | setReferenceFrame (const Frame *refFrame) |
Sets the reference Frame. | |
bool | settingAsReferenceFrameWillCreateALoop (const Frame *const frame) const |
Checks if setting the reference Frame will create a loop. | |
Frame modification | |
void | translate (vec3 &t) |
Translates the Frame. | |
void | translate (const vec3 &t) |
Translates the Frame. | |
void | rotate (quat &q) |
Rotates the Frame. | |
void | rotate (const quat &q) |
Rotates the Frame. | |
void | rotateAroundPoint (quat &rotation, const vec3 &point) |
Rotates the Frame around a point. | |
void | rotateAroundPoint (const quat &rotation, const vec3 &point) |
Rotates the Frame around a point. | |
void | alignWithFrame (const Frame *const frame, bool move=false, float threshold=0.0f) |
Aligns the Frame with another Frame. | |
void | projectOnLine (const vec3 &origin, const vec3 &direction) |
Projects the Frame on a line. | |
Coordinate system transformation of 3D coordinates | |
vec3 | coordinatesOf (const vec3 &src) const |
Transforms a 3D point to the Frame's coordinate system. | |
vec3 | inverseCoordinatesOf (const vec3 &src) const |
Transforms a 3D point from the Frame's coordinate system to the world coordinate system. | |
vec3 | localCoordinatesOf (const vec3 &src) const |
Transforms a 3D point to the Frame's local coordinate system. | |
vec3 | localInverseCoordinatesOf (const vec3 &src) const |
Transforms a 3D point from the Frame's local coordinate system to the world coordinate system. | |
vec3 | coordinatesOfIn (const vec3 &src, const Frame *const in) const |
Transforms a 3D point to another Frame's coordinate system. | |
vec3 | coordinatesOfFrom (const vec3 &src, const Frame *const from) const |
Transforms a 3D point from another Frame's coordinate system to the Frame's coordinate system. | |
Coordinate system transformation of vectors | |
vec3 | transformOf (const vec3 &src) const |
Transforms a 3D vector to the Frame's coordinate system. | |
vec3 | inverseTransformOf (const vec3 &src) const |
Transforms a 3D vector from the Frame's coordinate system to the world coordinate system. | |
vec3 | localTransformOf (const vec3 &src) const |
Transforms a 3D vector to the Frame's local coordinate system. | |
vec3 | localInverseTransformOf (const vec3 &src) const |
Transforms a 3D vector from the Frame's local coordinate system to the world coordinate system. | |
vec3 | transformOfIn (const vec3 &src, const Frame *const in) const |
Transforms a 3D vector to another Frame's coordinate system. | |
vec3 | transformOfFrom (const vec3 &src, const Frame *const from) const |
Transforms a 3D vector from another Frame's coordinate system to the Frame's coordinate system. | |
Constraint on the displacement | |
Constraint * | constraint () const |
Returns the current constraint applied to the Frame. | |
void | setConstraint (Constraint *const constraint) |
Sets the constraint attached to the Frame. | |
Associated matrices | |
mat4 | matrix () const |
Returns the transformation matrix of the Frame. | |
mat4 | worldMatrix () const |
Returns the world transformation matrix of the Frame. | |
void | setFromMatrix (const mat4 &m) |
Sets the Frame from a transformation matrix. | |
Inversion of the transformation | |
Signal | modified |
Signal emitted when the Frame is modified. | |
Frame | inverse () const |
Returns the inverse of the Frame. | |
Frame | worldInverse () const |
Returns the inverse of the Frame's world transformation. | |
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. Many functions are provided to transform a 3D point from one coordinate system (Frame) to another. 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.
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.
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()). Frames can hence easily be organized in a tree hierarchy, which root is the world coordinate system.
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. Constraints are especially useful for the ManipulatedFrame instances, in order to forbid some mouse motions.
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.
|
virtual |
Virtual destructor. Empty.
void alignWithFrame | ( | const Frame *const | frame, |
bool | move = false, | ||
float | threshold = 0.0f ) |
|
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.
Transforms a 3D point to the Frame's coordinate system.
src | The source point. |
Frame inverse | ( | ) | const |
Transforms a 3D point from the Frame's coordinate system to the world coordinate system.
src | The source point. |
Transforms a 3D vector from the Frame's coordinate system to the world coordinate system.
src | The source vector. |
Transforms a 3D point to the Frame's local coordinate system.
src | The source point. |
Transforms a 3D point from the Frame's local coordinate system to the world coordinate system.
src | The source point. |
Transforms a 3D vector from the Frame's local coordinate system to the world coordinate system.
src | The source vector. |
Transforms a 3D vector to the Frame's local coordinate system.
src | The source vector. |
mat4 matrix | ( | ) | const |
Returns the transformation matrix of the Frame.
quat orientation | ( | ) | const |
Projects the Frame on a line.
origin | The origin of the line. |
direction | The direction of the line. |
|
inline |
Returns the reference Frame.
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 another: see coordinatesOf(), localCoordinatesOf(), coordinatesOfIn() and their inverse functions. Vectors can also be converted using transformOf(), transformOfIn, localTransformOf() and their inverse functions.
Rotates the Frame around a point.
rotation | The rotation quaternion. |
point | The point to rotate around. |
Rotates the Frame around a point.
rotation | The rotation quaternion. |
point | The point to rotate around. |
|
inline |
Returns the rotation of the Frame.
Returns the Frame rotation, defined with respect to the referenceFrame(). Use orientation() to get the result in the world coordinates.
|
inline |
Sets the constraint attached to the Frame.
constraint | The new constraint. |
A NULL value means no constraint. The previous constraint should be deleted by the calling method if needed.
void setFromMatrix | ( | const mat4 & | m | ) |
Sets the Frame from a transformation matrix.
m | The transformation matrix. |
void setOrientation | ( | const quat & | orientation | ) |
void setOrientationWithConstraint | ( | quat & | orientation | ) |
void setPosition | ( | const vec3 & | position | ) |
void setPositionWithConstraint | ( | vec3 & | position | ) |
void setReferenceFrame | ( | const Frame * | refFrame | ) |
Sets the reference 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.
refFrame | The reference Frame. |
|
inline |
Sets the rotation of the Frame.
rotation | The new rotation of the Frame. |
Sets the rotation of the Frame, locally defined with respect to the referenceFrame(). Emits the modified() signal.
void setRotationWithConstraint | ( | quat & | rotation | ) |
bool settingAsReferenceFrameWillCreateALoop | ( | const Frame *const | frame | ) | const |
|
inline |
Sets the translation of the Frame.
translation | The new translation of the Frame. |
Sets the translation of the Frame, locally defined with respect to the referenceFrame(). Emits the modified() signal.
void setTranslationWithConstraint | ( | vec3 & | translation | ) |
Transforms a 3D vector to the Frame's coordinate system.
src | The source vector. |
|
inline |
Returns the translation of the Frame.
Returns the Frame translation, defined with respect to the referenceFrame(). Use position() to get the result in the world coordinates.
|
inline |
Returns the inverse of the Frame's world transformation.
The result Frame has a NULL referenceFrame() and a NULL constraint(). 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. Use inverse() for a local (i.e. with respect to referenceFrame()) transformation inverse.
mat4 worldMatrix | ( | ) | const |
Returns the world transformation matrix of the Frame.