Vector Math functions.
A 3-tuple (with 4-th element always set to 1)
dmVMath::Point3 p = dmVMath::Point3(x, y, z); // Create new point
float length_squared = p.getX() * p.getX() + p.getY() * p.getY() + p.getZ() * p.getZ();
A 3-tuple (with 4-th element always set to 0)
dmVMath::Vector3 p = dmVMath::Vector3(x, y, z); // Create new vector
float length_squared = p.getX() * p.getX() + p.getY() * p.getY() + p.getZ() * p.getZ();
A 4-tuple
dmVMath::Vector4 p = dmVMath::Vector4(x, y, z, w); // Create new vector
float length_squared = p.getX() * p.getX() + p.getY() * p.getY() + p.getZ() * p.getZ() + p.getW() * p.getW();
A 4-tuple representing a rotation rotation. The xyz
represents the axis, and the w
represents the angle.
dmVMath::Quat p = dmVMath::Quat(x, y, z, w); // Create new rotation. W is the angle
A 3x3 matrix
A 4x4 matrix
dot product between two vectors
a - the first vector
b - the second vector
dot_product - the dot product
dot product between two vectors
a - the first vector
b - the second vector
dot_product - the dot product
calculate length of a vector
v - the vector
length - the length
calculate length of a vector
v - the vector
length - the length
calculate length of a quaternion
v - the quaternion
length - the length
calculate squared length of a vector
v - the vector
length - the squared length
calculate squared length of a vector
v - the vector
length - the squared length
calculate squared length of a quaternion
v - the vector
length - the squared length
normalize a vector to length 1
v - the vector
n - the normalized vector
normalize a vector to length 1
v - the vector
n - the normalized vector
normalize a quaternion to length 1
v - the quaternion
n - the normalized quaternion
linear interpolate between two vectors
t - the unit time
a - the start vector (t == 0)
b - the end vector (t == 1)
v - the result vector v = a + (b - a) * t
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
linear interpolate between two vectors
t - the unit time
a - the start vector (t == 0)
b - the end vector (t == 1)
v - the result vector v = a + (b - a) * t
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
spherical linear interpolate between two vectors
t - the unit time
a - the start vector (t == 0)
b - the end vector (t == 1)
v - the result vector
spherical linear interpolate between two vectors
t - the unit time
a - the start vector (t == 0)
b - the end vector (t == 1)
v - the result vector
Interpolates along the shortest path between two quaternions
t - the unit time
a - the start vector (t == 0)
b - the end vector (t == 1)
v - the result vector
Divide two vectors per element: Vector3(a.x/b.x, a.y/b.y, a.z/b.z)
a - the operand
b - the dividend
v - the result vector
Divide two vectors per element: Vector3(a.x/b.x, a.y/b.y, a.z/b.z, a.w/b.w)
a - the operand
b - the dividend
v - the result vector
cross product between two vectors
a - the operand
b - the dividend
v - the result vector
Multiply two vectors per element: Vector3(a.x * b.x, a.y * b.y, a.z * b.z)
a - the first vector
b - the second vector
v - the result vector
Multiply two vectors per element: Vector3(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w)
a - the first vector
b - the second vector
v - the result vector
Return absolute value per element: Vector3(abs(v.x), abs(v.y), abs(v.z))
v - the vector
r - the result vector
Returns the conjugate of the quaternion: conj = -q
q - the quaternions
r - the result
rotate vector using quaternion
q - the rotation
v - the vector
r - the rotated vector
transpose matrix
m - the rotation
r - the transposed matrix
transpose matrix
m - the rotation
r - the transposed matrix
inverse matrix
m - the rotation
r - the transposed matrix
inverse matrix
m - the rotation
r - the transposed matrix
Compute the inverse of a 4x4 matrix, which is expected to be an affine matrix with an orthogonal upper-left 3x3 submatrix
m - the rotation
r - the transposed matrix
post multiply scale
m - the matrix
v - the scale vector
r - the scaled vector