Files
ConformalLabpp/code/include/matrix_utility.hpp
Tarik Moussa a2876b9cbf 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>
2026-05-09 01:15:35 +02:00

22 lines
729 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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