Skip to content

rtm/packing/quatd.h

#include "rtm/packing/quatd.h"

quat_ensure_positive_w

quatd quat_ensure_positive_w(const quatd& input)

Returns the quaternion on the hypersphere with a positive [w] component that represents the same 3D rotation as the input.

quat_from_positive_w

quatd quat_from_positive_w(const vector4d& input)

Returns a quaternion constructed from a vector3 representing the [xyz] components while reconstructing the [w] component by assuming it is positive. Note: When the squared length of [xyz] is very small, the square-root might not be very accurate when [w] is reconstructed. As such, the resulting quaternion might be near but not quite normalized. If high accuracy is required, make sure to normalize explicitly afterwards.