mirror of
https://github.com/recp/cglm.git
synced 2025-12-30 04:07:45 +00:00
quat: add new function glm_quat_make
Function takes in a 4 element float array and converts it into a quaternion. Signed-off-by: Vincent Davis Jr <vince@underview.tech>
This commit is contained in:
@@ -161,6 +161,10 @@ CGLM_EXPORT
|
||||
void
|
||||
glmc_quat_rotate_atm(mat4 m, versor q, vec3 pivot);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_quat_make(float * __restrict src, versor dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
versor dest);
|
||||
CGLM_INLINE void glm_quat_rotatev(versor q, vec3 v, vec3 dest);
|
||||
CGLM_INLINE void glm_quat_rotate(mat4 m, versor q, mat4 dest);
|
||||
CGLM_INLINE void glm_quat_make(float * restrict src, versor dest);
|
||||
*/
|
||||
|
||||
#ifndef cglm_quat_h
|
||||
@@ -885,4 +886,17 @@ glm_quat_rotate_atm(mat4 m, versor q, vec3 pivot) {
|
||||
glm_translate(m, pivotInv);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Create quaternion from pointer
|
||||
*
|
||||
* @param[in] src pointer to an array of floats
|
||||
* @param[out] dest quaternion
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_quat_make(float * __restrict src, versor dest) {
|
||||
dest[0] = src[0]; dest[1] = src[1];
|
||||
dest[2] = src[2]; dest[3] = src[3];
|
||||
}
|
||||
|
||||
#endif /* cglm_quat_h */
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
CGLM_INLINE mat4s glms_quat_rotate(mat4s m, versors q)
|
||||
CGLM_INLINE mat4s glms_quat_rotate_at(mat4s m, versors q, vec3s pivot)
|
||||
CGLM_INLINE mat4s glms_quat_rotate_atm(versors q, vec3s pivot)
|
||||
CGLM_INLINE void glms_quat_make(float * restrict src)
|
||||
*/
|
||||
|
||||
#ifndef cglms_quat_h
|
||||
@@ -565,4 +566,18 @@ glms_quat_(rotate_atm)(versors q, vec3s pivot) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Create CGLM quaternion from pointer
|
||||
*
|
||||
* @param[in] src pointer to an array of floats
|
||||
* @returns constructed quaternion from raw pointer
|
||||
*/
|
||||
CGLM_INLINE
|
||||
versors
|
||||
glms_quat_(make)(float * __restrict src) {
|
||||
versors dest;
|
||||
glm_quat_make(src, dest.raw);
|
||||
return dest;
|
||||
}
|
||||
|
||||
#endif /* cglms_quat_h */
|
||||
|
||||
Reference in New Issue
Block a user