docs: Doxygen-API + Validierungsprotokoll + Porting-Tutorial
Für einen Mathematiker der unabhängig validieren und eigene Forschung
einbringen möchte.
Doxygen-Kommentare (code/include/):
newton_solver.hpp — newton_euclidean(), newton_spherical(), newton_hyper_ideal()
je mit \param, \return, \note, \see inkl. mathematischer Begründung
(Konvexität, Vorzeichenkonvention, SparseQR-Fallback-Erklärung)
layout.hpp — euclidean_layout(), spherical_layout(), hyper_ideal_layout()
mit vollständiger Parameter-Doku, halfedge_uv-Semantik, Poincaré-Disk-Note
Neues Dokument:
doc/math/validation-protocol.md
7 reproduzierbare Checks mit konkreten Befehlen und erwartetem Output:
0. 170 Tests, 1 Skip
1. Gauss–Bonnet exakt (1e-10)
2. FD-Gradientencheck < 1e-6 für alle 3 Geometrien
3. Newton-Konvergenz < 50 Iterationen
4. τ ∈ SL(2,ℤ)-Fundamentaldomäne (3 Invarianten)
5. Möbius-Arithmetik (Inverse, Compose, from_three)
6. End-to-End-Pipeline
7. Manueller τ-Check für torus_4x4.off (Codebeispiel)
Neues Tutorial:
doc/tutorials/add-inversive-distance.md
Vollständiger Step-by-Step-Port von Phase 9a (Luo 2004):
Header anlegen, Energie/Gradient implementieren, FD-Check,
Newton-Wrapper, CMakeLists, Java-Referenzvergleich, Checkliste.
doc/getting-started.md:
Abschnitt "Known issues": macOS-Finder-Duplikate (rm-Befehl),
Warnung "First build 30–90s" (Tarball-Extraktion)
README.md:
Zwei neue Links in der Dokumentationstabelle (validation-protocol,
tutorial)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -452,6 +452,29 @@ inline void set_root_huv_2d(
|
||||
} // namespace detail
|
||||
|
||||
// ── Euclidean layout ──────────────────────────────────────────────────────────
|
||||
|
||||
/// Embed the mesh in ℝ² using the Euclidean metric encoded in x.
|
||||
///
|
||||
/// Runs priority-BFS trilateration: places vertices in order of BFS depth
|
||||
/// from the root face (largest 3D area), so errors accumulate last.
|
||||
/// For closed genus-g surfaces a CutGraph must be supplied — otherwise
|
||||
/// the layout will have a seam discontinuity (Layout2D::has_seam = true).
|
||||
///
|
||||
/// \param mesh Input surface mesh. Must have lambda0 and v_idx set in maps.
|
||||
/// \param x DOF vector returned by newton_euclidean().
|
||||
/// \param maps EuclideanMaps (lambda0, v_idx, e_idx).
|
||||
/// \param cut Optional cut graph (compute_cut_graph()). Pass nullptr for
|
||||
/// open meshes or if seams are acceptable.
|
||||
/// \param holonomy If non-null and cut != nullptr, receives the lattice
|
||||
/// translations ω_i ∈ ℂ per cut edge.
|
||||
/// Pass to compute_period_matrix() for the conformal modulus τ.
|
||||
/// \param normalise If true, calls normalise_euclidean() on the result:
|
||||
/// centroid → origin, major axis → x-axis (PCA).
|
||||
/// \return Layout2D with .uv[v] (per-vertex UV) and
|
||||
/// .halfedge_uv[h] (per-halfedge UV for texture atlasing).
|
||||
///
|
||||
/// \note halfedge_uv differs from uv at seam edges: the two sides of a cut
|
||||
/// carry different UV coordinates for proper GPU texture atlasing.
|
||||
inline Layout2D euclidean_layout(
|
||||
ConformalMesh& mesh,
|
||||
const std::vector<double>& x,
|
||||
@@ -571,6 +594,20 @@ inline Layout2D euclidean_layout(
|
||||
}
|
||||
|
||||
// ── Spherical layout ──────────────────────────────────────────────────────────
|
||||
|
||||
/// Embed the mesh on the unit sphere S² using the spherical metric encoded in x.
|
||||
///
|
||||
/// Runs priority-BFS trilateration using the spherical law of cosines.
|
||||
/// Typical use: genus-0 (sphere-like) surfaces after newton_spherical().
|
||||
///
|
||||
/// \param mesh Input genus-0 surface mesh.
|
||||
/// \param x DOF vector returned by newton_spherical().
|
||||
/// \param maps SphericalMaps.
|
||||
/// \param cut Optional cut graph (rarely needed for genus-0).
|
||||
/// \param holonomy If non-null, receives rotational holonomies (spherical).
|
||||
/// \param normalise If true, calls normalise_spherical(): rotates the centroid
|
||||
/// to the north pole (Rodrigues rotation formula).
|
||||
/// \return Layout3D with .xyz[v] ∈ S² ⊂ ℝ³ for each vertex.
|
||||
inline Layout3D spherical_layout(
|
||||
ConformalMesh& mesh,
|
||||
const std::vector<double>& x,
|
||||
@@ -670,6 +707,29 @@ inline Layout3D spherical_layout(
|
||||
}
|
||||
|
||||
// ── HyperIdeal layout (Poincaré disk) — exact trilateration ──────────────────
|
||||
|
||||
/// Embed the mesh in the Poincaré disk (H²) using the hyperbolic metric encoded in x.
|
||||
///
|
||||
/// Runs priority-BFS trilateration using exact Möbius-isometric placement:
|
||||
/// each new vertex is located by solving the hyperbolic law of cosines and
|
||||
/// applying a Möbius map to position it in the disk.
|
||||
/// For closed genus-g surfaces (g ≥ 1) a CutGraph is required.
|
||||
///
|
||||
/// \param mesh Input genus-g surface mesh (g ≥ 1).
|
||||
/// \param x DOF vector returned by newton_hyper_ideal()
|
||||
/// (vertex b_v and edge a_e variables).
|
||||
/// \param maps HyperIdealMaps (lambda0, v_idx, e_idx).
|
||||
/// \param cut CutGraph from compute_cut_graph(). Required for closed surfaces.
|
||||
/// \param holonomy If non-null, receives the Möbius maps T_i ∈ SU(1,1) per cut edge.
|
||||
/// Pass to compute_period_matrix() for holonomy analysis.
|
||||
/// \param normalise If true, calls normalise_hyperbolic(): iterative face-area-weighted
|
||||
/// Möbius centring (Fréchet mean, 30 iterations) → disk origin.
|
||||
/// \return Layout2D with .uv[v] ∈ Poincaré disk (|uv| < 1) for each vertex,
|
||||
/// and .halfedge_uv[h] for seam-aware texture atlasing.
|
||||
///
|
||||
/// \note All vertex positions satisfy |uv[v]| < 1 (inside the Poincaré disk)
|
||||
/// if the metric is hyperbolic. Points on or outside the boundary indicate
|
||||
/// a non-hyperbolic metric (Gauss–Bonnet violation).
|
||||
inline Layout2D hyper_ideal_layout(
|
||||
ConformalMesh& mesh,
|
||||
const std::vector<double>& x,
|
||||
|
||||
@@ -139,9 +139,29 @@ inline std::vector<double> line_search(
|
||||
} // namespace detail
|
||||
|
||||
// ── Euclidean Newton solver ────────────────────────────────────────────────────
|
||||
//
|
||||
// Minimises the Euclidean discrete conformal energy by solving G(x) = 0.
|
||||
// The Hessian H is PSD; Eigen::SimplicialLDLT is used directly.
|
||||
|
||||
/// Solve the Euclidean discrete conformal problem: find u ∈ ℝ^V such that
|
||||
/// Σ_{faces adj v} α_v(u) = Θ_v for all vertices v.
|
||||
///
|
||||
/// Starting from x0, Newton's method minimises E(u) (the Euclidean DCE energy,
|
||||
/// which is convex) by iterating u ← u − H⁻¹·G with backtracking line search.
|
||||
/// The Hessian H is the cotangent Laplacian — PSD with one zero eigenvalue on
|
||||
/// closed surfaces (gauge mode). A SparseQR fallback handles this automatically.
|
||||
///
|
||||
/// \param mesh Input triangulated surface (edges must carry lambda0 + theta_v).
|
||||
/// \param x0 Initial DOF vector (length = number of free vertices).
|
||||
/// Pass all-zeros for a flat start (typical).
|
||||
/// \param m EuclideanMaps: lambda0[e], theta_v[v], v_idx[v] must be set.
|
||||
/// Call setup_euclidean_maps() + compute_euclidean_lambda0_from_mesh()
|
||||
/// + enforce_gauss_bonnet() before passing here.
|
||||
/// \param tol Convergence threshold on max |G_i|. Default: 1e-8.
|
||||
/// \param max_iter Maximum Newton iterations. Default: 200.
|
||||
/// \return NewtonResult{x*, iterations, grad_inf_norm, converged}.
|
||||
///
|
||||
/// \note On closed meshes without a pinned vertex, SimplicialLDLT detects the
|
||||
/// gauge singularity and falls back to SparseQR automatically.
|
||||
///
|
||||
/// \see doc/math/discrete-conformal-theory.md §3 for the mathematical background.
|
||||
inline NewtonResult newton_euclidean(
|
||||
ConformalMesh& mesh,
|
||||
std::vector<double> x0,
|
||||
@@ -199,10 +219,28 @@ inline NewtonResult newton_euclidean(
|
||||
}
|
||||
|
||||
// ── Spherical Newton solver ───────────────────────────────────────────────────
|
||||
//
|
||||
// Solves G(x) = 0 for the spherical discrete conformal functional.
|
||||
// The Hessian H is NSD at the solution; −H is PSD, so we factorise −H and
|
||||
// solve (−H)·Δx = G ⟺ H·Δx = −G.
|
||||
|
||||
/// Solve the spherical discrete conformal problem: find u ∈ ℝ^V such that
|
||||
/// Σ_{faces adj v} α_v(u) = Θ_v for all vertices v (genus-0 / sphere-like surfaces).
|
||||
///
|
||||
/// The spherical DCE energy is *concave*, so the Hessian H is NSD at the solution.
|
||||
/// The solver factorises −H (which is PSD) and solves (−H)·Δx = G.
|
||||
/// A gauge vertex must be pinned (set v_idx = -1) to remove the rotational mode.
|
||||
///
|
||||
/// \param mesh Input triangulated surface, genus 0.
|
||||
/// \param x0 Initial DOF vector (length = free vertices, excluding gauge_vertex).
|
||||
/// All-zeros is a good start.
|
||||
/// \param m SphericalMaps: lambda0[e], theta_v[v], v_idx[v], gauge_vertex set.
|
||||
/// Call setup_spherical_maps() + compute_spherical_lambda0_from_mesh()
|
||||
/// + enforce_gauss_bonnet() (checks Σ(2π-Θ) > 0) before passing here.
|
||||
/// \param tol Convergence threshold on max |G_i|. Default: 1e-8.
|
||||
/// \param max_iter Maximum Newton iterations. Default: 200.
|
||||
/// \return NewtonResult{x*, iterations, grad_inf_norm, converged}.
|
||||
///
|
||||
/// \note Unlike the Euclidean solver, the spherical solver does NOT need a SparseQR
|
||||
/// fallback — the gauge vertex pins the null mode directly.
|
||||
///
|
||||
/// \see doc/math/geometry-modes.md §Spherical for sign-convention details.
|
||||
inline NewtonResult newton_spherical(
|
||||
ConformalMesh& mesh,
|
||||
std::vector<double> x0,
|
||||
@@ -258,17 +296,31 @@ inline NewtonResult newton_spherical(
|
||||
}
|
||||
|
||||
// ── HyperIdeal Newton solver ──────────────────────────────────────────────────
|
||||
//
|
||||
// Solves G(x) = 0 for the hyper-ideal discrete conformal functional.
|
||||
//
|
||||
// Gradient sign convention (opposite to Euclidean/Spherical):
|
||||
// G_v = Σ β_v − Θ_v, G_e = Σ α_e − θ_e (actual − target)
|
||||
//
|
||||
// The hyper-ideal energy is strictly convex (Springborn 2020), so H is PSD
|
||||
// and SimplicialLDLT (with SparseQR fallback) applies directly.
|
||||
//
|
||||
// The Hessian is computed by symmetric finite differences of G (see
|
||||
// hyper_ideal_hessian.hpp); replace with an analytical Hessian in Phase 5.
|
||||
|
||||
/// Solve the hyper-ideal discrete conformal problem: find (b, a) ∈ ℝ^{V+E} such that
|
||||
/// Σ β_v(b,a) = Θ_v and Σ α_e(b,a) = θ_e for all vertices v and edges e.
|
||||
///
|
||||
/// Used for genus-g surfaces (g ≥ 1) under hyperbolic cone metrics.
|
||||
/// The energy is *strictly convex* (Springborn 2020, Theorem 1.3), so Newton
|
||||
/// converges globally from any starting point.
|
||||
///
|
||||
/// DOF layout: first V_free entries are vertex variables b_v (hyper-ideal radii),
|
||||
/// followed by E entries for edge variables a_e (intersection angles).
|
||||
/// Use assign_all_dof_indices(mesh, maps) to set v_idx and e_idx automatically —
|
||||
/// no vertex needs to be pinned.
|
||||
///
|
||||
/// \param mesh Input triangulated surface, genus g ≥ 1.
|
||||
/// \param x0 Initial DOF vector (length = V + E). All-zeros typical.
|
||||
/// \param m HyperIdealMaps: lambda0[e], theta_v[v], v_idx[v], e_idx[e] set.
|
||||
/// Call setup_hyper_ideal_maps() + compute_hyper_ideal_lambda0_from_mesh().
|
||||
/// \param tol Convergence threshold on max |G_i|. Default: 1e-8.
|
||||
/// \param max_iter Maximum Newton iterations. Default: 200.
|
||||
/// \param hess_eps Finite-difference step for Hessian approximation. Default: 1e-5.
|
||||
/// (Phase 9b will replace this with an analytic Hessian.)
|
||||
/// \return NewtonResult{x*, iterations, grad_inf_norm, converged}.
|
||||
///
|
||||
/// \see Springborn (2020), Theorem 1.3 for the strict convexity proof.
|
||||
/// \see doc/math/geometry-modes.md §Hyper-ideal for DOF layout details.
|
||||
inline NewtonResult newton_hyper_ideal(
|
||||
ConformalMesh& mesh,
|
||||
std::vector<double> x0,
|
||||
|
||||
Reference in New Issue
Block a user