Add angle_between and matrix2_rotate

This commit is contained in:
gingerBill
2024-02-06 14:09:05 +00:00
parent 1ebb7f8e9d
commit b0675358c3
2 changed files with 62 additions and 0 deletions
+25
View File
@@ -267,6 +267,31 @@ to_ptr :: proc{vector_to_ptr, matrix_to_ptr}
vector_angle_between :: proc "contextless" (a, b: $V/[$N]$E) -> E {
a0 := normalize0(a)
b0 := normalize0(b)
return math.acos(dot(a0, b0))
}
quaternion64_angle_between :: proc "contextless" (a, b: $Q/quaternion64) -> f16 {
c := normalize0(conj(a) * b)
return math.acos(c.w)
}
quaternion128_angle_between :: proc "contextless" (a, b: $Q/quaternion128) -> f32 {
c := normalize0(conj(a) * b)
return math.acos(c.w)
}
quaternion256_angle_between :: proc "contextless" (a, b: $Q/quaternion256) -> f64 {
c := normalize0(conj(a) * b)
return math.acos(c.w)
}
angle_between :: proc{
vector_angle_between,
quaternion64_angle_between,
quaternion128_angle_between,
quaternion256_angle_between,
}
// Splines