Expand description
§dotloom-geometry
Headless 2D geometry for Dotloom: f64 primitives, affine transforms, exact
orientation predicates, curve intersections, split/trim/extend, dimension
geometry, dimensioned quantities and a bounding-box spatial index.
This crate has no DOM, window or GPU dependency.
use dotloom_geometry::{Point, Segment, Shape, Curve, intersect, ModelTolerance};
let a = Curve::Line(Segment::new(Point::new(0.0, 0.0), Point::new(2.0, 2.0)));
let b = Curve::Line(Segment::new(Point::new(0.0, 2.0), Point::new(2.0, 0.0)));
let hits = intersect::intersect(&a, &b, ModelTolerance::DEFAULT);
assert_eq!(hits.points[0].point, Point::new(1.0, 1.0));Re-exports§
pub use spatial::SpatialIndex;
Modules§
- dimension
- Dimension (measurement annotation) geometry.
- edit
- Split, trim and extend for lines, arcs, circles and line/arc polylines.
- intersect
- Curve/curve intersections.
- math
- Deterministic elementary functions.
- spatial
- Spatial index over bounding boxes (R*-tree via
rstar). - units
- Units and dimensioned quantities.
Structs§
- Aabb
- Axis-aligned bounding box. An empty box has
min > max. - Affine
- A 2D affine transform
[a b c d e f]with the SVG convention: - Anchor
- A named semantic anchor of a shape.
- Arc
- A circular arc:
center + radius·(cos θ, sin θ)forθ = start + sweep·t,t ∈ [0, 1]. - Circle
- A full circle.
- Cubic
Bez - Cubic Bézier curve.
- Flat
Path - Flattened ring/curve.
- Flatten
Tolerance - Maximum distance (model units) between a curve and its flattened polyline.
- Model
Tolerance - Model comparison tolerance:
|a - b| <= max(abs, rel * max(|a|, |b|)). - Path
- A Bézier path made of subpaths.
- Point
- A position in the plane (model units,
f64). Serialized as[x, y]. - Point
Shape - A point marker.
- Polygon
- Polygon with straight edges and optional holes (even-odd fill).
- Polyline
- Open or closed polyline whose segments may be circular arcs (DXF-style bulge).
- QuadBez
- Quadratic Bézier curve.
- Rect
- Axis-aligned rectangle in local coordinates (rotation lives in the entity transform).
- Screen
Tolerance - A screen-space tolerance in CSS pixels (pick radius, snap radius).
- Segment
- A straight line segment from
atob. - SubPath
- One subpath of a
Pathdecomposed into curves. - Text
- Text annotation. Height is the cap-to-descender line height in model units.
- Vector
- A displacement in the plane. Serialized as
[x, y].
Enums§
- Anchor
Kind - Semantic anchor kinds, used by snapping and constraints.
- Curve
- One elementary curve piece. Shapes decompose into these for intersections, trimming, hit-testing and tessellation.
- Geometry
Error - Errors produced by geometry operations.
- HAlign
- Horizontal text alignment.
- Linear
Kind - Classification of the linear part of a transform.
- Orientation
- Orientation of three points using an exact (adaptive-precision) predicate.
- PathEl
- Path element.
- Shape
- A canonical 2D shape.
- Shape
Kind - Shape kinds.
- Transform
Policy - How to handle transforms that a shape cannot represent exactly.
- VAlign
- Vertical text alignment.
Constants§
- MAX_
SHAPE_ POINTS - Limits enforced by
Shape::validateto bound memory/CPU on untrusted input. - MAX_
TEXT_ CHARS - Maximum text length in characters.
Functions§
- arc_
to_ cubics - Approximate an arc by cubic Béziers (≤ 90° each).
- circumcenter
- Circumcenter of a triangle,
Nonewhen collinear. - normalize_
angle - Normalize an angle into
[0, 2π). - normalize_
angle_ signed - Normalize an angle into
(-π, π]. - orientation
- Exact orientation test (Shewchuk’s adaptive predicate via the
robustcrate). - point_
in_ ring - Even-odd point-in-ring test using exact orientation predicates.
- ring_
signed_ area - Signed area (positive = counter-clockwise).
Type Aliases§
- GeoResult
- Result alias for geometry operations.