create quaternion header

This commit is contained in:
2025-03-11 17:54:52 +01:00
parent 925bca5eda
commit 9d1c63d635

44
src/util/vec/quaternion.h Normal file
View File

@@ -0,0 +1,44 @@
#include "../../error.h"
#include "float3.h"
#include "float4.h"
// converts euler angles into quaternion
static inline float4 quaternion_from_euler(float3 euler) {
(void)euler;
error(STATUS_ERROR, __FILE_NAME__, __LINE__, "this function is not implemented"); // TODO: write an implementation for this function
}
// converts quaternion into euler angles
static inline float3 quaternion_to_euler(float4 q) {
(void)q;
error(STATUS_ERROR, __FILE_NAME__, __LINE__, "this function is not implemented"); // TODO: write an implementation for this function
}
// adds two quaternions
static inline float4 quaternion_add(float4 q1, float4 q2) {
(void)q1, (void)q2;
error(STATUS_ERROR, __FILE_NAME__, __LINE__, "this function is not implemented"); // TODO: write an implementation for this function
}
// subtracts two quaternions
static inline float4 quaternion_sub(float4 q1, float4 q2) {
(void)q1, (void)q2;
error(STATUS_ERROR, __FILE_NAME__, __LINE__, "this function is not implemented"); // TODO: write an implementation for this function
}
// multiplies two quaternions
static inline float4 quaternion_mul(float4 q1, float4 q2) {
return (float4){
q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z,
q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y,
q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z,
q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x,
};
}
// multiplies two quaternions
static inline float4 quaternion_div(float4 q1, float4 q2) {
(void)q1, (void)q2;
error(STATUS_ERROR, __FILE_NAME__, __LINE__, "this function is not implemented"); // TODO: write an implementation for this function
}