mirror of
https://github.com/recp/cglm.git
synced 2026-01-05 22:59:12 +00:00
Compute quaternion rotating a vector into another
Both `vec3` inputs should be of unit length; returns a unit quaternion.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
CGLM_INLINE versors glms_quat_init(float x, float y, float z, float w)
|
||||
CGLM_INLINE versors glms_quatv(float angle, vec3s axis)
|
||||
CGLM_INLINE versors glms_quat(float angle, float x, float y, float z)
|
||||
CGLM_INLINE versors glms_quat_from_vecs(vec3s a, vec3s b)
|
||||
CGLM_INLINE float glms_quat_norm(versors q)
|
||||
CGLM_INLINE versors glms_quat_normalize(versors q)
|
||||
CGLM_INLINE float glms_quat_dot(versors p, versors q)
|
||||
@@ -147,10 +148,25 @@ glms_quat(float angle, float x, float y, float z) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief compute quaternion rotating vector A to vector B
|
||||
*
|
||||
* @param[in] a vec3 (must have unit length)
|
||||
* @param[in] b vec3 (must have unit length)
|
||||
* @returns quaternion (of unit length)
|
||||
*/
|
||||
CGLM_INLINE
|
||||
versors
|
||||
glms_quat_from_vecs(vec3s a, vec3s b) {
|
||||
versors dest;
|
||||
glm_quat_from_vecs(a.raw, b.raw, dest.raw);
|
||||
return dest;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns norm (magnitude) of quaternion
|
||||
*
|
||||
* @param[out] q quaternion
|
||||
* @param[in] q quaternion
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
|
||||
Reference in New Issue
Block a user