Skip to content

rtm/vqvf.h

#include "rtm/vqvf.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

vqvf vqv_cast(vqvd input)

Casts a VQV transform float64 variant to a float32 variant.

vqv_from_matrix

vqvf vqv_from_matrix(matrix3x3f input)

Converts a pure rotation 3x3 matrix into a VQV transform. The translation/scale will be the identity.

vqvf vqv_from_matrix(matrix3x4f input)

Converts a 3x4 affine matrix into a VQV transform.

vqv_mul

vqvf vqv_mul(vqvf lhs, vqvf 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

vqvf vqv_mul_no_scale(vqvf lhs, vqvf 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

vector4f vqv_mul_point3(vector4f point, vqvf 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

vector4f vqv_mul_point3_no_scale(vector4f point, vqvf 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

vqvf vqv_inverse(vqvf 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.

vqvf vqv_inverse(vqvf input, vector4f fallback_scale, float threshold=1.0E-8F)

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

vqvf vqv_inverse_no_scale(vqvf input)

Returns the inverse of the input VQV transform ignoring 3D scale. The resulting VQV transform will have the input scale.

vqv_normalize

vqvf vqv_normalize(vqvf input)

Returns a VQV transforms with the rotation part normalized.

vqv_lerp

vqvf vqv_lerp(vqvf start, vqvf end, float 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

vqvf vqv_lerp_no_scale(vqvf start, vqvf end, float 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

vqvf vqv_slerp(vqvf start, vqvf end, float 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

vqvf vqv_slerp_no_scale(vqvf start, vqvf end, float alpha)

Per component spherical interpolation of the two inputs at the specified alpha. See quat_slerp(..)

vqv_is_finite

bool vqv_is_finite(vqvf input)

Returns true if the input VQV does not contain any NaN or Inf, otherwise false.

vqv_set

constexpr vqvf vqv_set(quatf rotation, vector4f translation, vector4f scale)

Creates a VQV transform from a rotation quaternion, a translation, and a 3D scale.

vqv_identity

vqvf vqv_identity()

Returns the identity VQV transform.

The return value also converts to vqvd.