Add x y z w fields to quaternion types; Improve linalg quaternion mathematics

This commit is contained in:
gingerBill
2020-01-01 16:14:00 +00:00
parent e9e2ab240d
commit 16a7c55334
5 changed files with 299 additions and 62 deletions
+2 -2
View File
@@ -17,10 +17,10 @@ vector_dot :: proc(a, b: $T/[$N]$E) -> (c: E) where IS_NUMERIC(E) {
return;
}
quaternion128_dot :: proc(a, b: $T/quaternion128) -> (c: f32) {
return real(a)*real(a) + imag(a)*imag(b) + jmag(a)*jmag(b) + kmag(a)*kmag(b);
return a.w*a.w + a.x*b.x + a.y*b.y + a.z*b.z;
}
quaternion256_dot :: proc(a, b: $T/quaternion256) -> (c: f64) {
return real(a)*real(a) + imag(a)*imag(b) + jmag(a)*jmag(b) + kmag(a)*kmag(b);
return a.w*a.w + a.x*b.x + a.y*b.y + a.z*b.z;
}
dot :: proc{vector_dot, quaternion128_dot, quaternion256_dot};