#pragma once
// Copyright (c) 2024-2026 Tarik Moussa.
// SPDX-License-Identifier: MIT


// 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 each row of `from` (homogeneous
/// 4-vector) to the corresponding row of `to`: `R · fromᵀ = toᵀ`.
/// Computed as `R = toᵀ · (fromᵀ)⁻¹`.  Same as Java
/// `MatrixUtility.makeMappingMatrix()`.
inline Eigen::Matrix4d makeMappingMatrix(const Eigen::Matrix4d& from,
                                         const Eigen::Matrix4d& to) {
    return to.transpose() * from.transpose().inverse();
}

} // namespace conformallab
