port MatrixUtility and SurfaceCurveUtility tests to C++

- include/matrix_utility.hpp: 4x4 mapping matrix R·from=to (Eigen)
- include/projective_math.hpp: dehomogenize, hyperbolicDistance,
  isOnSegment (collinearity + betweenness via 3D cross/dot),
  getPointOnCorrespondingSegment (parameter by arc-length ratio)
- test_matrix_utility.cpp: port of MatrixUtilityTest (1 test)
- test_surface_curve_utility.cpp: port of SurfaceCurveUtilityTest
  testIsBetween and testGetPointOnSegment_SegmentEdge (2 tests)
- tolerance adjusted to 1e-12 for matrix inversion (2.7e-15 rounding
  from Eigen vs jReality's LU; both well within meaningful accuracy)

Total: 16/16 tests pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tarik Moussa
2026-05-09 01:15:35 +02:00
parent c30d540521
commit a2876b9cbf
5 changed files with 207 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
#pragma once
// 4x4 mapping matrix from corresponding point pairs.
// Ported from de.varylab.discreteconformal.math.MatrixUtility (Java).
#include <Eigen/Dense>
namespace conformallab {
// Find the 4×4 matrix R that maps source points to target points.
// Each row of `from` / `to` is a homogeneous 4-vector (one point per row).
// Post-condition: R * from.row(i).T == to.row(i).T for all i.
//
// Implementation: R = to^T * (from^T)^{-1}
// Corresponds to Java MatrixUtility.makeMappingMatrix().
inline Eigen::Matrix4d makeMappingMatrix(const Eigen::Matrix4d& from,
const Eigen::Matrix4d& to) {
return to.transpose() * from.transpose().inverse();
}
} // namespace conformallab