![]() |
TrinityCore
|
A rigid body RT (rotation-translation) transformation. More...
#include <CoordinateFrame.h>
Static Public Member Functions | |
static CoordinateFrame | fromXYZYPRRadians (float x, float y, float z, float yaw=0.0f, float pitch=0.0f, float roll=0.0f) |
static CoordinateFrame | fromXYZYPRDegrees (float x, float y, float z, float yaw=0.0f, float pitch=0.0f, float roll=0.0f) |
Public Attributes | |
Matrix3 | rotation |
Point3 | translation |
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.
any | Must be in one of the following forms: |
G3D::CoordinateFrame::CoordinateFrame | ( | ) |
Initializes to the identity coordinate frame.
|
inline |
G3D::CoordinateFrame::CoordinateFrame | ( | const class UprightFrame & | f | ) |
G3D::CoordinateFrame::CoordinateFrame | ( | class BinaryInput & | b | ) |
|
inline |
void G3D::CoordinateFrame::deserialize | ( | class BinaryInput & | b | ) |
|
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 |
bool G3D::CoordinateFrame::fuzzyEq | ( | const CoordinateFrame & | other | ) | const |
bool G3D::CoordinateFrame::fuzzyIsIdentity | ( | ) | 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 |
|
inline |
Computes the inverse of this coordinate frame.
bool G3D::CoordinateFrame::isIdentity | ( | ) | 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.
Ray G3D::CoordinateFrame::lookRay | ( | ) | const |
Returns the ray starting at the camera origin travelling in direction CoordinateFrame::lookVector.
|
inline |
The direction this camera is looking (its negative z axis)
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.
goal | Step from this towards goal |
maxTranslation | Meters |
maxRotation | Radians |
void G3D::CoordinateFrame::normalToObjectSpace | ( | const Array< Vector3 > & | v, |
Array< Vector3 > & | vout | ||
) | const |
void G3D::CoordinateFrame::normalToWorldSpace | ( | const Array< Vector3 > & | v, |
Array< Vector3 > & | vout | ||
) | const |
|
inline |
|
inline |
Compose: create the transformation that is other followed by this.
|
inline |
|
inline |
|
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 |
Transforms the point into world space.
void G3D::CoordinateFrame::pointToWorldSpace | ( | const Array< Point3 > & | v, |
Array< Point3 > & | vout | ||
) | const |
|
inline |
void G3D::CoordinateFrame::serialize | ( | class BinaryOutput & | b | ) | const |
Any G3D::CoordinateFrame::toAny | ( | ) | const |
Converts the CFrame to an Any.
Matrix4 G3D::CoordinateFrame::toMatrix4 | ( | ) | const |
See also Matrix4::approxCoordinateFrame
|
inline |
Takes the coordinate frame into object space. this->inverse() * c
std::string G3D::CoordinateFrame::toXML | ( | ) | const |
Produces an XML serialization of this coordinate frame.
std::string G3D::CoordinateFrame::toXYZYPRDegreesString | ( | ) | const |
|
inline |
Up direction for this camera (its y axis).
Transforms the vector into object space (no translation).
void G3D::CoordinateFrame::vectorToObjectSpace | ( | const Array< Vector3 > & | v, |
Array< Vector3 > & | vout | ||
) | const |
Transforms the vector into world space (no translation).
void G3D::CoordinateFrame::vectorToWorldSpace | ( | const Array< Vector3 > & | v, |
Array< Vector3 > & | vout | ||
) | const |
Matrix3 G3D::CoordinateFrame::rotation |
Takes object space points to world space.
Point3 G3D::CoordinateFrame::translation |
The origin of this coordinate frame in world space (or its parent's space, if nested).