Add quat_inv
This commit is contained in:
@@ -173,3 +173,13 @@ quat_t quat_from_to(vec4_t v0, vec4_t v1) {
|
||||
return quat_norm(q);
|
||||
}
|
||||
}
|
||||
|
||||
quat_t quat_inv(quat_t q) {
|
||||
float l = q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w;
|
||||
l = -1.0 / l;
|
||||
q.x = q.x * l;
|
||||
q.y = q.y * l;
|
||||
q.z = q.z * l;
|
||||
q.w = -q.w * l;
|
||||
return q;
|
||||
}
|
||||
|
||||
@@ -16,3 +16,4 @@ quat_t quat_from_euler(float x, float y, float z);
|
||||
quat_t quat_lerp(quat_t from, quat_t to, float s);
|
||||
float quat_dot(quat_t a, quat_t b);
|
||||
quat_t quat_from_to(vec4_t v0, vec4_t v1);
|
||||
quat_t quat_inv(quat_t q);
|
||||
|
||||
@@ -420,6 +420,7 @@ declare function quat_from_euler(x: f32, y: f32, z: f32): quat_t;
|
||||
declare function quat_lerp(from: quat_t, to: quat_t, s: f32): quat_t;
|
||||
declare function quat_dot(a: quat_t, b: quat_t): f32;
|
||||
declare function quat_from_to(v0: vec4_t, v1: vec4_t): quat_t;
|
||||
declare function quat_inv(q: quat_t): quat_t;
|
||||
|
||||
declare type mat3_t = {
|
||||
m?: f32_ptr;
|
||||
|
||||
Reference in New Issue
Block a user