Back to class index
float3x3[Class Summary]
v
zero[static][const]
identity[static][const]
nan[static][const]
ctor (+3 overloads)
ToQuat()[const]
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]
ScaleRow(row,scalar)
ScaleCol(col,scalar)
PositiveX/Y/Z()[const]
ptr() (+1 overload)
SetRow(row,data) (+2 overloads)
SetCol(column,data) (+2 overloads)
Set(...) (+3 overloads)
SetIdentity()
SwapColumns(col1,col2)
SwapRows(row1,row2)
SetRotatePart/X/Y/Z(...) (+1 overload)
operator=(rhs) (+1 overload)
Determinant()[const]
DeterminantSymmetric()[const]
Inverse(epsilon)
InverseFast(epsilon)
SolveAxb(b,x)[const]
Inverted()[const]
InverseColOrthogonal()
InverseOrthogonalUniformScale()
InverseOrthonormal()
InverseSymmetric()
Transpose()
Transposed()[const]
InverseTranspose()
InverseTransposed()[const]
Trace()[const]
Orthonormalize(...)
RemoveScale()
Transform(vector)[const] (+1 overload)
TransformLeft(lhs)[const]
Transform(vector)[const]
BatchTransform(...)[const] (+3 overloads)
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(rotate,scale)[const] (+1 overload)
Mul(rhs)[const] (+5 overloads)
MulPos(rhs)[const] (+1 overload)
MulDir(rhs)[const] (+1 overload)
RotateX/Y/Z(angleRadians)[static]
RotateAxisAngle(...)[static]
RotateFromTo(...)[static]
LookAt(...)[static]
RandomRotation(lcg)[static]
RandomGeneral(...)[static]
FromQuat(orientation)[static]
FromRS(rotate,scale)[static] (+1 overload)
FromEuler***(ex,ey,ex2)[static]
Scale(sx,sy,sz)[static] (+1 overload)
ScaleAlongAxis(axis,scalingFactor)[static]
UniformScale(uniformScale)[static]
ShearX/Y/Z(yFactor,zFactor)[static]
Mirror(p)[static]
OrthographicProjection/YZ/XZ/XY(target)[static]

float3x3::LookAt

Syntax

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

Creates a LookAt matrix.

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

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 &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. This matrix can be used as the 'world transform' of an object. 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().