foundation tier

foundation-planar-geometry

Planar rings in drawing units: parse and emit M/L/Z path text with the source's decimal scale kept, shoelace area with the closing edge and holes, bounding box, centroid, edge lengths, and the isometric projection a plan is drawn with. Policy-free and database-free.

Planar rings in drawing units: parse and emit M/L/Z path text with the source's decimal scale kept, shoelace area with the closing edge and holes, bounding box, centroid, edge lengths, and the isometric projection a plan is drawn with. Policy-free and database-free.

Tierfoundation
Rolevalue_object
Pathcrates/foundation/planar-geometry
Edition2021
Targetsfoundation_planar_geometry
Public items28 across 1 module
Tests13

What it is for

Planar rings in drawing units.

A drawing arrives as path text: M6.00,472.67L6.02,6.00 ... Z, repeated once per ring. This crate turns that text into rings of decimal points and back, keeping the decimal scale the source wrote (6.00 stays 6.00, 266.6 stays 266.6), so a ring that was not edited emits the text it was read from. Everything computed from a ring -- area, bounding box, centroid, edge lengths, an isometric projection -- is a pure function over those points.

No policy lives here: what a ring means (a lot, a road, a building) and what is acceptable for it belong to the crate that knows the domain.

Capabilities

crate root

Planar rings in drawing units.

Item
fn parse_path(d : & str) -> Result <Vec <Ring>, PathError>
fn iso_project(u : f64, v : f64, z : f64) ->(f64, f64)

BBox

Planar rings in drawing units.

Item
pub struct BBox
BBox :: fn width(& self) -> f64
BBox :: fn height(& self) -> f64
fn bbox(rings : & Ring) -> Option <BBox>

PathError

Planar rings in drawing units.

Item
pub enum PathError

Point

Planar rings in drawing units.

Item
pub struct Point
Point :: fn new(x : Decimal, y : Decimal) -> Self

Ring

Planar rings in drawing units.

Item
pub struct Ring
fn emit_path(rings : & Ring, closed_repeat : bool) -> String
fn signed_area(ring : & Ring) -> f64
fn area(rings : & Ring) -> f64
fn centroid(ring : & Ring) ->(f64, f64)
fn edge_lengths(ring : & Ring) -> Vec <f64>
fn perimeter(ring : & Ring) -> f64
fn rounding_bound(ring : & Ring) -> f64

Region

A region of the plane made of polygons, and the set arithmetic between regions.

Item
pub struct Region
Region :: fn empty() -> Self
Region :: fn from_ring(ring : & (f64, f64)) -> Self
Region :: fn from_rings(rings : & Vec <(f64, f64)>) -> Self
Region :: fn union(& self, other : & Region) -> Region
Region :: fn difference(& self, other : & Region) -> Region
Region :: fn intersection(& self, other : & Region) -> Region
Region :: fn is_empty(& self) -> bool
Region :: fn area(& self) -> f64
Region :: fn polygon_count(& self) -> usize
Region :: fn rings(& self) -> Vec <Vec <(f64, f64)>>

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

foundation_planar_geometry

Public surface

`crate root`

ItemWhat it is
pub struct PointOne vertex, in the drawing's units, with the decimal scale the source wrote.
Point :: fn new(x : Decimal, y : Decimal) -> Self
pub struct RingA closed ring of vertices
pub struct BBoxThe axis-aligned box around a set of rings.
BBox :: fn width(& self) -> f64
BBox :: fn height(& self) -> f64
pub enum PathError
fn parse_path(d : & str) -> Result <Vec <Ring>, PathError>Parse path text made of M x,y, L x,y and Z into rings
fn emit_path(rings : & Ring, closed_repeat : bool) -> StringEmit rings as `M x,y L x,y ..
fn signed_area(ring : & Ring) -> f64Signed shoelace area of one ring, including the closing edge
fn area(rings : & Ring) -> f64Area of a figure made of rings: rings wound like the largest ring add, rings wound the other way are holes and subtract, and a ring of no area adds nothing
fn bbox(rings : & Ring) -> Option <BBox>Bounding box over every vertex of every ring
fn centroid(ring : & Ring) ->(f64, f64)Area-weighted centroid of one ring
fn edge_lengths(ring : & Ring) -> Vec <f64>Length of each edge, in vertex order, closing edge last.
fn perimeter(ring : & Ring) -> f64Perimeter of one ring, closing edge included.
fn rounding_bound(ring : & Ring) -> f64The most the area of a ring can differ from the area of the exact figure it was rounded from: half a unit of the coarsest decimal scale among its vertices, times the perimeter
fn iso_project(u : f64, v : f64, z : f64) ->(f64, f64)The 30-degree isometric projection: (u, v, z) in plan becomes ((u - v) cos 30°, (u + v) / 2 - z).

`region`

ItemWhat it is
pub struct RegionA set of polygons, possibly with holes, in drawing units.
Region :: fn empty() -> SelfThe empty region.
Region :: fn from_ring(ring : & (f64, f64)) -> SelfOne simple polygon from a closed ring (the closing edge implied).
Region :: fn from_rings(rings : & Vec <(f64, f64)>) -> SelfThe union of every ring: overlapping rings merge, disjoint rings stay apart.
Region :: fn union(& self, other : & Region) -> Region
Region :: fn difference(& self, other : & Region) -> RegionWhat is in self and not in other.
Region :: fn intersection(& self, other : & Region) -> Region
Region :: fn is_empty(& self) -> bool
Region :: fn area(& self) -> f64Unsigned area, holes subtracted.
Region :: fn polygon_count(& self) -> usize
Region :: fn rings(& self) -> Vec <Vec <(f64, f64)>>Every ring as points: each polygon's exterior followed by its holes.

Re-exports. Exported here, defined elsewhere.

ExportDefined in
Regionregion::Region

Boundary

Depends on no other workspace tier.

Shares tier foundation with 28 other crates: foundation-audit-log, foundation-basemodels, foundation-bounded-io, foundation-conversation-closure, foundation-crypto-sign, foundation-decisioning, foundation-encounter-vocabulary, foundation-fs-metadata, … (28 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)foundation
Architectural role (taxonomy)value_object
Locationcrates/foundation/planar-geometry
Vocabulary in force (lexicon)current

Dependencies

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
geo^0.33noalways
rust_decimal^1serdenoalways
thiserror^2noalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
rust_decimal_macros^1noalways

Build. None.

Depended on by. 1 workspace crate.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_domain_subdivision_plan["domain-subdivision-plan"] -->|uses| SELF
  SELF["foundation-planar-geometry"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
libfoundation_planar_geometry`src/lib.rs`

Error model

Error typeNamed by
PathErrorparse_path

Operational characteristics

PropertyEvidence
async public surfacenone detected
async runtimenone detected
database accessnone detected
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

1 workspace crate depends on this one: domain-subdivision-plan.

Verification

KindCount
Unit tests13
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root14010
region101

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc2028
Public modules with a //! block11
pie showData
    title Public items with rustdoc
    "Documented" : 20
    "No rustdoc detected" : 8

Metrics

MetricValue
Rust source files2
Source lines563
Code lines456
Public API items28
Public modules1
Tests13
Examples0
Cargo features0
Direct runtime dependencies3
Workspace reverse dependencies1
pie showData
    title Public API by kind
    "enum" : 1
    "function" : 10
    "method" : 13
    "struct" : 4
pie showData
    title Rust source composition
    "Code" : 456
    "Blank or comment" : 107

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

All foundation · Manual