Fix non-unit normals in mesh convex hull compiler.

PiperOrigin-RevId: 928777934
Change-Id: I43d7adcf4c5781b57f0af9805a8ce01ebc2e3872
This commit is contained in:
Yuval Tassa
2026-06-08 14:39:40 -07:00
committed by Copybara-Service
parent ae2e8aa940
commit 986d73c062
4 changed files with 24 additions and 2 deletions
+20
View File
@@ -182,6 +182,26 @@ TEST_F(UserUtilTest, VectorToStringEmpty) {
EXPECT_EQ(VectorToString(v), "");
}
TEST_F(UserUtilTest, MakeNormal) {
double a[3] = {0, 0, 0};
double b[3] = {1, 0, 0};
double c[3] = {0, 1, 0};
double normal[3];
double nrm = mjuu_makenormal(normal, a, b, c);
EXPECT_EQ(nrm, 1.0);
EXPECT_THAT(normal, ElementsAre(0, 0, 1));
}
TEST_F(UserUtilTest, MakeNormalDegenerate) {
double a[3] = {0, 0, 0};
double b[3] = {1, 0, 0};
double c[3] = {2, 0, 0};
double normal[3] = {0, 0, 0};
double nrm = mjuu_makenormal(normal, a, b, c);
EXPECT_EQ(nrm, 1.0);
EXPECT_THAT(normal, ElementsAre(1, 0, 0));
}
// utility: modified Gram-Schmidt to orthogonalize columns of Q (n x n)
static void gramSchmidt(double* Q, int n) {
for (int j = 0; j < n; j++) {