Back to class index
float3x4[Class Summary]
v
zero[static][const]
identity[static][const]
nan[static][const]
ctor (+6 overloads)
GetScale()[const]
operator[](row) (+1 overload)
At(row,col) (+1 overload)
Row(row) (+1 overload)
Row3(row) (+1 overload)
Col(col)[const]
Col3(col)[const]
Diagonal()[const]
ScaleRow3(row,scalar)
ScaleRow(row,scalar)
ScaleCol(col,scalar)
Float3x3Part()[const]
TranslatePart()[const]
RotatePart()[const]
PositiveX/Y/Z()[const]
ptr() (+1 overload)
SetRow(row,data) (+3 overloads)
SetCol(column,data) (+2 overloads)
Set(...) (+3 overloads)
Set3x3Part(rotation)
SetIdentity()
SwapColumns(col1,col2)
SwapRows(row1,row2)
SetTranslatePart(tx,ty,tz) (+1 overload)
SetRotatePart/X/Y/Z(...) (+2 overloads)
operator=(rhs) (+2 overloads)
Determinant()[const]
Inverse(epsilon)
Inverted()[const]
InverseColOrthogonal()
InverseOrthogonalUniformScale()
InverseOrthonormal()
Transpose3()
Transposed3()[const]
InverseTranspose()
InverseTransposed()[const]
Trace()[const]
Orthonormalize(...)
RemoveScale()
TransformPos(pointVector)[const] (+1 overload)
TransformDir(directionVector)[const] (+2 overloads)
Transform(vector)[const]
BatchTransformPos(...)[const] (+3 overloads)
BatchTransformDir(...)[const] (+3 overloads)
BatchTransform(...)[const] (+1 overload)
operator*(rhs)[const] (+4 overloads)
operator/(scalar)[const]
operator+(rhs)[const]
operator-(rhs)[const] (+1 overload)
operator+()[const]
operator*=(scalar)
operator/=(scalar)
operator+=(rhs)
operator-=(rhs)
IsFinite()[const]
IsIdentity(epsilon)[const]
IsLowerTriangular(epsilon)[const]
IsUpperTriangular(epsilon)[const]
IsInvertible(epsilon)[const]
IsSymmetric(epsilon)[const]
IsSkewSymmetric(epsilon)[const]
HasUnitaryScale(epsilonSq)[const]
HasNegativeScale()[const]
HasUniformScale(epsilon)[const]
IsRowOrthogonal(epsilon)[const]
IsColOrthogonal(epsilon)[const]
IsColOrthogonal3(epsilon)[const]
IsOrthonormal(epsilon)[const]
Equals(other,epsilon)[const]
ToString()[const]
SerializeToString()[const]
ToString2()[const]
ToEuler***()[const]
ExtractScale()[const]
Decompose(...)[const] (+2 overloads)
Mul(rhs)[const] (+3 overloads)
MulPos(pointVector)[const] (+1 overload)
MulDir(directionVector)[const] (+1 overload)
Mul(vector)[const]
Translate(tx,ty,tz)[static] (+2 overloads)
RotateX/Y/Z(...)[static] (+1 overload)
RotateAxisAngle(...)[static] (+1 overload)
RotateFromTo(...)[static] (+1 overload)
RandomGeneral(...)[static]
RandomRotation(lcg)[static]
FromQuat(orientation)[static] (+1 overload)
FromTRS(...)[static] (+2 overloads)
FromEuler***(ex,ey,ex2)[static]
Scale(sx,sy,sz)[static] (+4 overloads)
ScaleAlongAxis(...)[static] (+1 overload)
UniformScale(uniformScale)[static] (+1 overload)
ShearX/Y/Z(yFactor,zFactor)[static]
Mirror(p)[static]
OrthographicProjection/YZ/XZ/XY(target)[static]
LookAt(...)[static] (+1 overload)

float3x4::LookAt

Syntax

float3x4 float3x4::LookAt(const float3 &localForward, const float3 &targetDirection, const float3 &localUp, const float3 &worldUp); [7 lines of code]

Creates a LookAt matrix from a look-at direction vector.

A LookAt matrix is a rotation matrix that orients an object to face towards a specified target direction.

Note
The position of (the translation performed by) the resulting matrix will be set to (0,0,0), i.e. the object will be placed to origin. Call SetTranslatePart() on the resulting matrix to set the position of the model.

Parameters

const float3 &localForwardSpecifies the forward direction in the local space of the object. This is the direction the model is facing at in its own local/object space, often +X (1,0,0), +Y (0,1,0) or +Z (0,0,1). The vector to pass in here depends on the conventions you or your modeling software is using, and it is best pick one convention for all your objects, and be consistent. This input parameter must be a normalized vector. const float3 &targetDirectionSpecifies the desired world space direction the object should look at. This function will compute a rotation matrix which will rotate the localForward vector to orient towards this targetDirection vector. This input parameter must be a normalized vector. const float3 &localUpSpecifies the up direction in the local space of the object. This is the up direction the model was authored in, often +Y (0,1,0) or +Z (0,0,1). The vector to pass in here depends on the conventions you or your modeling software is using, and it is best to pick one convention for all your objects, and be consistent. This input parameter must be a normalized vector. This vector must be perpendicular to the vector localForward, i.e. localForward.Dot(localUp) == 0. const float3 &worldUpSpecifies the global up direction of the scene in world space. Simply rotating one vector to coincide with another (localForward->targetDirection) would cause the up direction of the resulting orientation to drift (e.g. the model could be looking at its target its head slanted sideways). To keep the up direction straight, this function orients the localUp direction of the model to point towards the specified worldUp direction (as closely as possible). The worldUp and targetDirection vectors cannot be collinear, but they do not need to be perpendicular either.

Return Value

A matrix that maps the given local space forward direction vector to point towards the given target direction, and the given local up direction towards the given target world up direction. The returned matrix M is orthonormal with a determinant of +1. For the matrix M it holds that M * localForward = targetDirection, and M * localUp lies in the plane spanned by the vectors targetDirection and worldUp.

See Also

RotateFromTo().

Syntax

float3x4 float3x4::LookAt(const float3 &eyePos, const float3 &targetPos, const float3 &localForward, const float3 &localUp, const float3 &worldUp); [8 lines of code]

Creates a LookAt matrix from source and target points.

A LookAt matrix is a rotation matrix that orients an object to face towards a specified target direction.

Note
The position of (the translation performed by) the resulting matrix will be set to eyePos, i.e. the object will be placed to the given eye position.

Note
Be aware that the convention of a 'LookAt' matrix in MathGeoLib differs from e.g. GLM. In MathGeoLib, the returned matrix is a mapping from local space to world space, meaning that the returned matrix can be used as the 'world transform' for any 3D object (camera or not). The view space is the local space of the camera, so this function returns the mapping view->world. In GLM, the LookAt function is tied to cameras only, and it returns the inverse mapping world->view.

Parameters

const float3 &eyePosThe position the observer is at, i.e. the position of the model. const float3 &targetPosThe target position the model should be looking at. The vectors eyePos and targetPos cannot be equal, and the direction specified by targetPos - eyePos cannot be collinear to the direction passed in worldUp. const float3 &localForwardSpecifies the forward direction in the local space of the object. This is the direction the model is facing at in its own local/object space, often +X (1,0,0), +Y (0,1,0) or +Z (0,0,1). The vector to pass in here depends on the conventions you or your modeling software is using, and it is best pick one convention for all your objects, and be consistent. This input parameter must be a normalized vector. const float3 &localUpSpecifies the up direction in the local space of the object. This is the up direction the model was authored in, often +Y (0,1,0) or +Z (0,0,1). The vector to pass in here depends on the conventions you or your modeling software is using, and it is best to pick one convention for all your objects, and be consistent. This input parameter must be a normalized vector. This vector must be perpendicular to the vector localForward, i.e. localForward.Dot(localUp) == 0. const float3 &worldUpSpecifies the global up direction of the scene in world space. Simply rotating one vector to coincide with another (localForward->targetDirection) would cause the up direction of the resulting orientation to drift (e.g. the model could be looking at its target its head slanted sideways). To keep the up direction straight, this function orients the localUp direction of the model to point towards the specified worldUp direction (as closely as possible). The worldUp and targetDirection vectors cannot be collinear, but they do not need to be perpendicular either.

Return Value

A matrix that maps the given local space forward direction vector to point towards the given target direction, and the given local up direction towards the given target world up direction. The returned matrix M is orthonormal with a determinant of +1. For the matrix M it holds that M * localForward = targetDirection, and M * localUp lies in the plane spanned by the vectors targetDirection and worldUp.

See Also

RotateFromTo().