rtm/vqmf.h¶
#include "rtm/vqmf.h"
vqm_cast¶
vqmf vqm_cast(const vqmd& input)
Casts a VQM transform float64 variant to a float32 variant.
vqm_set¶
vqmf vqm_set(quatf rotation, vector4f translation, matrix3x3f scale_shear)
Creates a VQM transform from a rotation quaternion, a translation, and a 3x3 scale/shear matrix. The scale/shear matrix applies before the rotation: p' = p * M * R + t.
vqmf vqm_set(quatf rotation, vector4f translation, vector4f scale)
Creates a VQM transform from a rotation quaternion, a translation, and a 3D scale.
vqm_get_scale_shear¶
matrix3x3f vqm_get_scale_shear(vqmf input)
Returns the scale/shear part of a VQM transform as a 3x3 matrix. The matrix applies before the rotation: p' = p * M * R + t.
vqm_from_matrix¶
vqmf vqm_from_matrix(matrix3x3f input)
Converts a 3x3 matrix into a VQM transform. The matrix can contain rotation, scale, shear, and reflection. The translation is zero. The rotation part is a pure rotation. If the matrix contains a reflection, the scale/shear part contains it. More than one VQM transform gives the same matrix. The function returns one of them.
vqmf vqm_from_matrix(matrix3x4f input)
Converts a 3x4 affine matrix into a VQM transform. See vqm_from_matrix(matrix3x3f) for the rotation and the scale/shear parts.
vqm_get_rotation¶
quatf vqm_get_rotation(vqmf input)
Returns the rotation part of a VQM transform.
vqm_set_rotation¶
vqmf vqm_set_rotation(vqmf input, quatf rotation)
Sets the rotation part of a VQM and returns the new value.
vqm_get_translation¶
vector4f vqm_get_translation(vqmf input)
Returns the translation part of a VQM transform. The [w] component is undefined.
vqm_set_translation¶
vqmf vqm_set_translation(vqmf input, vector4f translation)
Sets the translation part of a VQM and returns the new value.
vqm_get_scale¶
vector4f vqm_get_scale(vqmf input)
Returns the scale part of a VQM transform: the diagonal of the scale/shear matrix [m00, m11, m22]. The rows of the scale/shear matrix are the x, y, and z axes. When the matrix contains shear, the scale is not the length of a row. Use vqm_get_scale_shear to get the full matrix.
vqm_set_scale¶
vqmf vqm_set_scale(vqmf input, vector4f scale)
Sets the scale part of a VQM and returns the new value. The function sets the diagonal of the scale/shear matrix and keeps the other entries (the shear).
vqm_set_scale_shear¶
vqmf vqm_set_scale_shear(vqmf input, matrix3x3f scale_shear)
Sets the scale/shear part of a VQM and returns the new value. The matrix applies before the rotation: p' = p * M * R + t.
vqm_add¶
vqmf vqm_add(vqmf lhs, vqmf rhs)
Adds two VQM transforms.
vqm_mul¶
vqmf vqm_mul(vqmf lhs, vqmf rhs)
Multiplies two VQM transforms. Multiplication order is as follow: local_to_world = vqm_mul(local_to_object, object_to_world)
vqmf vqm_mul(vqmf vqm, float scalar)
Multiplies a VQM transform with a scalar.
vqm_mul_point3¶
vector4f vqm_mul_point3(vector4f point, vqmf vqm)
Multiplies a VQM transform and a 3D point. Multiplication order is as follow: world_position = vqm_mul_point3(local_position, local_to_world)
vqm_mul_vector3¶
vector4f vqm_mul_vector3(vector4f vec3, vqmf vqm)
Multiplies a VQM transform and a 3D vector. The translation does not apply. Multiplication order is as follow: world_direction = vqm_mul_vector3(local_direction, local_to_world)
vqm_inverse¶
vqmf vqm_inverse(vqmf input)
Returns the inverse of the input VQM transform. If the scale/shear part has a zero determinant (e.g. zero scale), the result is undefined. For a safe alternative, supply a fallback scale value and a threshold.
vqmf vqm_inverse(vqmf input, vector4f fallback_scale, float threshold=1.0E-8F)
Returns the inverse of the input VQM transform. If the scale/shear part has a determinant whose absolute value is below the supplied threshold, the function uses the fallback scale in place of the scale/shear part. The fallback scale part has no shear. It must not contain a zero scale.
matrix_from_vqm¶
matrix3x4f matrix_from_vqm(vqmf input)
Converts a VQM transform into a 3x4 affine matrix.
vqm_normalize¶
vqmf vqm_normalize(vqmf input)
Returns a VQM transform with the rotation part normalized.
vqm_lerp¶
vqmf vqm_lerp(vqmf start, vqmf end, float alpha)
Per component linear interpolation of the two inputs at the specified alpha. The function interpolates the rotation with quat_lerp(..). It interpolates the translation and each axis of the scale/shear part with vector_lerp(..). The formula used is: ((1.0 - alpha) * start) + (alpha * end).
vqm_slerp¶
vqmf vqm_slerp(vqmf start, vqmf end, float alpha)
Spherical interpolation of the two inputs at the specified alpha. The function interpolates the rotation with quat_slerp(..) and the translation with vector_lerp(..). The scale is the diagonal of the scale/shear part. The function interpolates the scale with vector_eerp(..) and the remaining shear with vector_lerp(..). If the two values of a scale have a different sign or if one value is zero, the function interpolates that lane of the rows of the scale/shear part with vector_lerp(..).
vqm_is_finite¶
bool vqm_is_finite(vqmf input)
Returns true if the input VQM does not contain any NaN or Inf, otherwise false.
vqm_identity¶
vqmf vqm_identity()
Returns the identity VQM transform.
The return value also converts to vqmd.