Back to class index
float4x4[Class Summary]
v
zero[static][const]
identity[static][const]
nan[static][const]
ctor (+6 overloads)
GetScale()[const]
ComplementaryProjection()[const]
operator[](row) (+1 overload)
At(row,col) (+1 overload)
Row(row) (+1 overload)
Row3(row)[const]
Col(col)[const]
Diagonal()[const]
ScaleRow3(row,scalar)
ScaleRow(row,scalar)
ScaleCol3(col,scalar)
ScaleCol(col,scalar)
Float3x3Part()[const]
Float3x4Part() (+1 overload)
TranslatePart()[const]
RotatePart()[const]
X/Y/Z()[const]
ptr() (+1 overload)
SetRow3(row,data) (+2 overloads)
SetRow(row,data) (+3 overloads)
SetCol3(column,data) (+2 overloads)
SetCol(column,data) (+3 overloads)
Set(...) (+3 overloads)
Set3x3Part(rotation)
Set3x4Part(rotateTranslate)
SetIdentity()
SwapColumns(col1,col2)
SwapRows(row1,row2)
SetTranslatePart(tx,ty,tz) (+2 overloads)
SetRotatePart/X/Y/Z(...) (+2 overloads)
operator=(rhs) (+4 overloads)
Determinant3()[const]
Determinant4()[const]
SubMatrix(i,j)[const]
Minor(i,j)[const]
Adjugate()[const]
CholeskyDecompose(outL)[const]
LUDecompose(outLower,outUpper)[const]
Inverse(epsilon)
Inverted()[const]
InverseColOrthogonal()
InverseOrthogonalUniformScale()
InverseOrthonormal()
Transpose()
Transposed()[const]
InverseTranspose()
InverseTransposed()[const]
Trace()[const]
Orthogonalize3(...) (+1 overload)
Orthonormalize3(...) (+1 overload)
RemoveScale()
Pivot()
TransformPos(pointVector)[const] (+2 overloads)
TransformDir(directionVector)[const] (+2 overloads)
Transform(vector)[const]
TransformPos(...)[const] (+1 overload)
TransformDir(...)[const] (+1 overload)
Transform(...)[const] (+1 overload)
operator*(rhs)[const] (+5 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]
IsIdempotent(epsilon)[const]
HasUnitaryScale(epsilon)[const]
HasNegativeScale()[const]
HasUniformScale(epsilon)[const]
IsRowOrthogonal3(epsilon)[const]
IsColOrthogonal3(epsilon)[const]
IsOrthonormal3(epsilon)[const]
Equals(other,epsilon)[const]
ContainsProjection(epsilon)[const]
ToString()[const]
SerializeToString()[const]
ToString2()[const]
ToEuler***()[const]
ExtractScale()[const]
Decompose(...)[const] (+3 overloads)
Abs()[const]
Mul(rhs)[const] (+3 overloads)
MulPos(pointVector)[const] (+1 overload)
MulDir(directionVector)[const] (+1 overload)
Mul(vector)[const]
Translate(tx,ty,tz)[static] (+1 overload)
RotateX/Y/Z(...)[static] (+1 overload)
RotateAxisAngle(...)[static] (+1 overload)
RotateFromTo(...)[static] (+1 overload)
RandomGeneral(...)[static]
RotateFromTo(...)[static] (+1 overload)
FromQuat(orientation)[static] (+1 overload)
FromTRS(...)[static] (+3 overloads)
FromEuler***(x2,y,x)[static]
Scale(sx,sy,sz)[static] (+2 overloads)
ScaleAlongAxis(...)[static] (+1 overload)
UniformScale(uniformScale)[static] (+1 overload)
ShearX/Y/Z(yFactor,zFactor)[static]
Mirror(p)[static]
D3DOrthoProjLH(...)[static]
D3DOrthoProjRH(...)[static]
D3DPerspProjLH(...)[static]
D3DPerspProjRH(...)[static]
OpenGLOrthoProjLH(...)[static]
OpenGLOrthoProjRH(...)[static]
OpenGLPerspProjLH(...)[static]
OpenGLPerspProjRH(...)[static]
OrthographicProjection/YZ/XZ/XY(target)[static]
LookAt(...)[static] (+1 overload)

float4x4::LookAt

Syntax

float4x4 float4x4::LookAt(const float3 &localForward, const float3 &targetDirection, const float3 &localUp, const float3 &worldUp); [8 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

float4x4 float4x4::LookAt(const float3 &eyePos, const float3 &targetPos, const float3 &localForward, const float3 &localUp, const float3 &worldUp); [9 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().