# monge-rs

[![crates.io](https://img.shields.io/crates/v/monge-rs.svg)](https://crates.io/crates/monge-rs)
[![docs.rs](https://img.shields.io/docsrs/monge-rs)](https://docs.rs/monge-rs)

Monge's theorem for fleet mathematics — homothetic centers, radical axes,
zero-holonomy consensus, and Pythagorean48 verification.

Designed to integrate with Forgemaster's constraint theory (jc1-ct-bridge).

## Overview

Monge's theorem (1781) states that for three circles in the plane, the three
pairs of external homothetic centers are collinear. This crate implements the
theorem and several generalizations for multi-agent consensus and fleet geometry.

## Modules

- **geometry** — Core types: `Circle`, `Sphere`, 3D paraboloid lifting, nD
  Lassak generalization
- **homothetic** — External and internal homothetic centers with Monge
  collinearity verification
- **radical_axis** — Radical axis as a 1-cocycle in Čech cohomology, radical
  center computation
- **consensus** — Zero-holonomy Lyapunov consensus protocol using Monge
  geometry for multi-agent systems
- **p48** — Pythagorean48: zero-drift verification across 48 lattice
  directions from 6 primitive Pythagorean triples

## Quick Start

```rust
use nalgebra::Vector2;
use monge_rs::geometry::Circle;
use monge_rs::homothetic::{external_homothetic_center, monge_collinear_area};

let c1 = Circle::new(Vector2::new(0.0, 0.0), 1.0);
let c2 = Circle::new(Vector2::new(4.0, 0.0), 2.0);
let c3 = Circle::new(Vector2::new(2.0, 3.0), 1.5);

// External homothetic centers
let s12 = external_homothetic_center(&c1, &c2).unwrap();
let s23 = external_homothetic_center(&c2, &c3).unwrap();
let s31 = external_homothetic_center(&c3, &c1).unwrap();

// Verify Monge collinearity (area ≈ 0)
let area = monge_collinear_area(&c1, &c2, &c3).unwrap();
assert!(area < 1e-10);
```

## Zero-Holonomy Consensus

Three agents with positions and trust radii converge to a common line
(the Monge line) through the zero-holonomy protocol. Holonomy measures
the area of the triangle formed by external homothetic centers —
convergence is exponential with contraction factor λ = 2/3 for equal
radii.

## Pythagorean48

Verifies zero-drift Monge consistency across 48 lattice directions
generated from the 6 primitive Pythagorean triples with c ≤ 37:

| (a, b, c)      | Directions |
|----------------|------------|
| (3, 4, 5)      | 8          |
| (5, 12, 13)    | 8          |
| (8, 15, 17)    | 8          |
| (7, 24, 25)    | 8          |
| (9, 40, 41)    | 8          |
| (11, 60, 61)   | 8          |
| **Total**      | **48**     |

## License

MIT OR Apache-2.0
