From 06449fb862afea9092e33adfda416d5b677ad05a Mon Sep 17 00:00:00 2001 From: Nathan Wiebe Neufeldt Date: Mon, 15 Apr 2019 16:08:07 -0400 Subject: Fix bug in mat4x4_orthonormalize The Gram-Schmidt process was incorrect, resulting in non-orthogonal columns. --- linmath.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/linmath.h b/linmath.h index de9bae8..96725e8 100644 --- a/linmath.h +++ b/linmath.h @@ -321,12 +321,11 @@ LINMATH_H_FUNC void mat4x4_orthonormalize(mat4x4 R, mat4x4 M) s = vec3_mul_inner(R[1], R[2]); vec3_scale(h, R[2], s); vec3_sub(R[1], R[1], h); - vec3_norm(R[2], R[2]); + vec3_norm(R[1], R[1]); - s = vec3_mul_inner(R[1], R[2]); + s = vec3_mul_inner(R[0], R[2]); vec3_scale(h, R[2], s); - vec3_sub(R[1], R[1], h); - vec3_norm(R[1], R[1]); + vec3_sub(R[0], R[0], h); s = vec3_mul_inner(R[0], R[1]); vec3_scale(h, R[1], s); -- cgit v1.2.3