Vector Math functions.
Namespace: | dmVMath |
Include: | #include <dmsdk/dlib/vmath.h> |
TYPES | |
---|---|
Matrix3 | 3x3 matrix |
Matrix4 | 4x4 matrix |
Point3 | 3-tuple |
Quat | 4-tuple representing a rotation |
Vector3 | 3-tuple |
Vector4 | 4-tuple |
FUNCTIONS | |
---|---|
Matrix4 AppendScale(Matrix4 m, Vector3 v) | post multiply scale |
Vector3 Cross(Vector3 a, Vector3 b) | cross product between two vectors |
Vector3 DivPerElem(Vector3 a, Vector3 b) | divide two vectors per element |
Vector4 DivPerElem(Vector4 a, Vector4 b) | divide two vectors per element |
float Dot(Vector3 a, Vector3 b) | dot product between two vectors |
float Dot(Vector4 a, Vector4 b) | dot product between two vectors |
Matrix3 Inverse(Matrix3 m) | inverse matrix |
Matrix4 Inverse(Matrix4 m) | inverse matrix |
float Length(Vector3 v) | calculate length of a vector |
float Length(Vector3 v) | calculate length of a vector |
float Length(Quat v) | calculate length of a quaternion |
float Length(Vector3 v) | calculate squared length of a vector |
float Length(Vector4 v) | calculate squared length of a vector |
float Length(Quat v) | calculate squared length of a quaternion |
Vector3 Lerp(float t, Vector3 a, Vector3 b) | linear interpolate between two vectors |
Vector4 Lerp(float t, Vector4 a, Vector4 b) | linear interpolate between two vectors |
Vector3 MulPerElem(Vector3 a, Vector3 b) | multiply two vectors per element |
Vector4 MulPerElem(Vector4 a, Vector4 b) | multiply two vectors per element |
Vector3 MulPerElem(Vector3 v) | abs value per element |
Quat MulPerElem(Quat q) | conjugate of quaternion |
Vector3 Normalize(Vector3 v) | normalize a vector to length 1 |
Vector4 Normalize(Vector4 v) | normalize a vector to length 1 |
Quat Normalize(Quat v) | normalize a quaternion to length 1 |
Matrix4 OrthoInverse(Matrix4 m) | Compute the inverse of a 4x4 matrix, which is expe... |
Vector3 Rotate(Quat q, Vector3 v) | rotate vector using quaternion |
Vector3 Slerp(float t, Vector3 a, Vector3 b) | spherical linear interpolate between two vectors |
Vector4 Slerp(float t, Vector4 a, Vector4 b) | spherical linear interpolate between two vectors |
Quat Slerp(float t, Quat a, Quat b) | spherical linear interpolate between two vectors |
Matrix3 Transpose(Matrix3 m) | transpose matrix |
Matrix4 Transpose(Matrix4 m) | transpose matrix |
Matrix4 AppendScale(Matrix4 m, Vector3 v)
post multiply scale
PARAMETERS
Matrix4 |
m |
the matrix |
Vector3 |
v |
the scale vector |
RETURNS
Matrix4 |
the scaled vector |
Vector3 Cross(Vector3 a, Vector3 b)
cross product between two vectors
PARAMETERS
Vector3 |
a |
the operand |
Vector3 |
b |
the dividend |
RETURNS
Vector3 |
the result vector |
Vector3 DivPerElem(Vector3 a, Vector3 b)
Divide two vectors per element: Vector3(a.x/b.x, a.y/b.y, a.z/b.z)
PARAMETERS
Vector3 |
a |
the operand |
Vector3 |
b |
the dividend |
RETURNS
Vector3 |
the result vector |
Vector4 DivPerElem(Vector4 a, Vector4 b)
Divide two vectors per element: Vector3(a.x/b.x, a.y/b.y, a.z/b.z, a.w/b.w)
PARAMETERS
Vector4 |
a |
the operand |
Vector4 |
b |
the dividend |
RETURNS
Vector4 |
the result vector |
float Dot(Vector3 a, Vector3 b)
dot product between two vectors
PARAMETERS
Vector3 |
a |
the first vector |
Vector3 |
b |
the second vector |
RETURNS
float |
the dot product |
float Dot(Vector4 a, Vector4 b)
dot product between two vectors
PARAMETERS
Vector4 |
a |
the first vector |
Vector4 |
b |
the second vector |
RETURNS
float |
the dot product |
Matrix3 Inverse(Matrix3 m)
inverse matrix
PARAMETERS
Matrix3 |
m |
the rotation |
RETURNS
Matrix3 |
the transposed matrix |
Matrix4 Inverse(Matrix4 m)
inverse matrix
PARAMETERS
Matrix4 |
m |
the rotation |
RETURNS
Matrix4 |
the transposed matrix |
float Length(Vector3 v)
calculate length of a vector
PARAMETERS
Vector3 |
v |
the vector |
RETURNS
float |
the length |
float Length(Vector3 v)
calculate length of a vector
PARAMETERS
Vector3 |
v |
the vector |
RETURNS
float |
the length |
float Length(Quat v)
calculate length of a quaternion
PARAMETERS
Quat |
v |
the quaternion |
RETURNS
float |
the length |
float Length(Vector3 v)
calculate squared length of a vector
PARAMETERS
Vector3 |
v |
the vector |
RETURNS
float |
the squared length |
float Length(Vector4 v)
calculate squared length of a vector
PARAMETERS
Vector4 |
v |
the vector |
RETURNS
float |
the squared length |
float Length(Quat v)
calculate squared length of a quaternion
PARAMETERS
Quat |
v |
the vector |
RETURNS
float |
the squared length |
Vector3 Lerp(float t, Vector3 a, Vector3 b)
linear interpolate between two vectors
PARAMETERS
float |
t |
the unit time |
Vector3 |
a |
the start vector (t == 0) |
Vector3 |
b |
the end vector (t == 1) |
RETURNS
Vector3 |
the result vector v = a + (b - a) * t |
EXAMPLES
dmVMath::Vector3 v0 = dmVMath::Lerp(0.0f, a, b); // v0 == a
dmVMath::Vector3 v1 = dmVMath::Lerp(1.0f, a, b); // v1 == b
dmVMath::Vector3 v2 = dmVMath::Lerp(2.0f, a, b); // v2 == a + (b-a) * 2.0f
Vector4 Lerp(float t, Vector4 a, Vector4 b)
linear interpolate between two vectors
PARAMETERS
float |
t |
the unit time |
Vector4 |
a |
the start vector (t == 0) |
Vector4 |
b |
the end vector (t == 1) |
RETURNS
Vector4 |
the result vector v = a + (b - a) * t |
EXAMPLES
dmVMath::Vector4 v0 = dmVMath::Lerp(0.0f, a, b); // v0 == a
dmVMath::Vector4 v1 = dmVMath::Lerp(1.0f, a, b); // v1 == b
dmVMath::Vector4 v2 = dmVMath::Lerp(2.0f, a, b); // v2 == a + (b-a) * 2.0f
Vector3 MulPerElem(Vector3 a, Vector3 b)
Multiply two vectors per element: Vector3(a.x * b.x, a.y * b.y, a.z * b.z)
PARAMETERS
Vector3 |
a |
the first vector |
Vector3 |
b |
the second vector |
RETURNS
Vector3 |
the result vector |
Vector4 MulPerElem(Vector4 a, Vector4 b)
Multiply two vectors per element: Vector3(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w)
PARAMETERS
Vector4 |
a |
the first vector |
Vector4 |
b |
the second vector |
RETURNS
Vector4 |
the result vector |
Vector3 MulPerElem(Vector3 v)
Return absolute value per element: Vector3(abs(v.x), abs(v.y), abs(v.z))
PARAMETERS
Vector3 |
v |
the vector |
RETURNS
Vector3 |
the result vector |
Quat MulPerElem(Quat q)
Returns the conjugate of the quaternion: conj = -q
PARAMETERS
Quat |
q |
the quaternions |
RETURNS
Quat |
the result |
Vector3 Normalize(Vector3 v)
normalize a vector to length 1
PARAMETERS
Vector3 |
v |
the vector |
RETURNS
Vector3 |
the normalized vector |
Vector4 Normalize(Vector4 v)
normalize a vector to length 1
PARAMETERS
Vector4 |
v |
the vector |
RETURNS
Vector4 |
the normalized vector |
Quat Normalize(Quat v)
normalize a quaternion to length 1
PARAMETERS
Quat |
v |
the quaternion |
RETURNS
Quat |
the normalized quaternion |
Matrix4 OrthoInverse(Matrix4 m)
Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix
PARAMETERS
Matrix4 |
m |
the rotation |
RETURNS
Matrix4 |
the transposed matrix |
Vector3 Rotate(Quat q, Vector3 v)
rotate vector using quaternion
PARAMETERS
Quat |
q |
the rotation |
Vector3 |
v |
the vector |
RETURNS
Vector3 |
the rotated vector |
Vector3 Slerp(float t, Vector3 a, Vector3 b)
spherical linear interpolate between two vectors
PARAMETERS
float |
t |
the unit time |
Vector3 |
a |
the start vector (t == 0) |
Vector3 |
b |
the end vector (t == 1) |
RETURNS
Vector3 |
the result vector |
Vector4 Slerp(float t, Vector4 a, Vector4 b)
spherical linear interpolate between two vectors
PARAMETERS
float |
t |
the unit time |
Vector4 |
a |
the start vector (t == 0) |
Vector4 |
b |
the end vector (t == 1) |
RETURNS
Vector4 |
the result vector |
Quat Slerp(float t, Quat a, Quat b)
Interpolates along the shortest path between two quaternions
PARAMETERS
float |
t |
the unit time |
Quat |
a |
the start vector (t == 0) |
Quat |
b |
the end vector (t == 1) |
RETURNS
Quat |
the result vector |
Matrix3 Transpose(Matrix3 m)
transpose matrix
PARAMETERS
Matrix3 |
m |
the rotation |
RETURNS
Matrix3 |
the transposed matrix |
Matrix4 Transpose(Matrix4 m)
transpose matrix
PARAMETERS
Matrix4 |
m |
the rotation |
RETURNS
Matrix4 |
the transposed matrix |
A 3x3 matrix
A 4x4 matrix
A 3-tuple (with 4-th element always set to 1)
A 4-tuple representing a rotation rotation. The xyz
represents the axis, and the w
represents the angle.
A 3-tuple (with 4-th element always set to 0)
A 4-tuple