rtm/vqvd.h¶
#include "rtm/vqvd.h"
WARNING: VQV transforms do NOT form a group. It has no well defined multiplication and inverse. This is because when non-uniform scale is rotated (e.g. as the result of two VQV multiplying), shear is introduced and there is no place to store it. As such, VQV discards the introduced shear which is mathematically incorrect. As a result of this, VQV multiplication is NOT associative and the inverse is incorrect. USE AT YOUR OWN RISK.
vqv_cast¶
vqvd vqv_cast(vqvf input)
Casts a VQV transform float32 variant to a float64 variant.
vqv_from_matrix¶
vqvd vqv_from_matrix(matrix3x3d input)
Converts a pure rotation 3x3 matrix into a VQV transform. The translation/scale will be the identity.
vqvd vqv_from_matrix(matrix3x4d input)
Converts a 3x4 affine matrix into a VQV transform.
vqv_mul¶
vqvd vqv_mul(vqvd lhs, vqvd rhs)
Multiplies two VQV transforms. Multiplication order is as follow: local_to_world = vqv_mul(local_to_object, object_to_world) NOTE: When scale is present, multiplication will not properly handle skew/shear, use affine matrices if you have issues.
vqv_mul_no_scale¶
vqvd vqv_mul_no_scale(vqvd lhs, vqvd rhs)
Multiplies two VQV transforms ignoring 3D scale. The resulting VQV transform will have the LHS scale. Multiplication order is as follow: local_to_world = vqv_mul(local_to_object, object_to_world)
vqv_mul_point3¶
vector4d vqv_mul_point3(vector4d point, vqvd vqv)
Multiplies a VQV transform and a 3D point. Multiplication order is as follow: world_position = vqv_mul_point3(local_position, local_to_world)
vqv_mul_point3_no_scale¶
vector4d vqv_mul_point3_no_scale(vector4d point, vqvd vqv)
Multiplies a VQV transform and a 3D point ignoring 3D scale. Multiplication order is as follow: world_position = vqv_mul_point3_no_scale(local_position, local_to_world)
vqv_inverse¶
vqvd vqv_inverse(vqvd input)
Returns the inverse of the input VQV transform. If zero scale is contained, the result is undefined. For a safe alternative, supply a fallback scale value and a threshold.
vqvd vqv_inverse(vqvd input, vector4d fallback_scale, double threshold=1.0E-8)
Returns the inverse of the input VQV transform. If the input scale has an absolute value below the supplied threshold, the fallback value is used instead.
vqv_inverse_no_scale¶
vqvd vqv_inverse_no_scale(vqvd input)
Returns the inverse of the input VQV transform ignoring 3D scale. The resulting VQV transform will have the input scale.
vqv_normalize¶
vqvd vqv_normalize(vqvd input)
Returns a VQV transforms with the rotation part normalized.
vqv_lerp¶
vqvd vqv_lerp(vqvd start, vqvd end, double alpha)
Per component linear interpolation of the two inputs at the specified alpha. The formula used is: ((1.0 - alpha) * start) + (alpha * end). Interpolation is stable and will return 'start' when alpha is 0.0 and 'end' when it is 1.0. This is the same instruction count when FMA is present but it might be slightly slower due to the extra multiplication compared to: start + (alpha * (end - start)).
vqv_lerp_no_scale¶
vqvd vqv_lerp_no_scale(vqvd start, vqvd end, double alpha)
Per component linear interpolation of the two inputs at the specified alpha. The formula used is: ((1.0 - alpha) * start) + (alpha * end). Interpolation is stable and will return 'start' when alpha is 0.0 and 'end' when it is 1.0. This is the same instruction count when FMA is present but it might be slightly slower due to the extra multiplication compared to: start + (alpha * (end - start)). The resulting VQV transform will have the start scale.
vqv_slerp¶
vqvd vqv_slerp(vqvd start, vqvd end, double alpha)
Per component spherical interpolation of the two inputs at the specified alpha. The function interpolates the rotation with quat_slerp(..), the translation with vector_lerp(..), and the scale with vector_eerp(..). If the two scales of a component have a different sign or if one scale is zero, the function uses vector_lerp(..) for that component.
vqv_slerp_no_scale¶
vqvd vqv_slerp_no_scale(vqvd start, vqvd end, double alpha)
Per component spherical interpolation of the two inputs at the specified alpha. See quat_slerp(..)
vqv_is_finite¶
bool vqv_is_finite(vqvd input)
Returns true if the input VQV does not contain any NaN or Inf, otherwise false.
vqv_set¶
constexpr vqvd vqv_set(quatd rotation, vector4d translation, vector4d scale)
Creates a VQV transform from a rotation quaternion, a translation, and a 3D scale.
vqv_identity¶
vqvd vqv_identity()
Returns the identity VQV transform.
The return value also converts to vqvf.