Skip to main content

Crate dotloom_geometry

Crate dotloom_geometry 

Source
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.
CubicBez
Cubic Bézier curve.
FlatPath
Flattened ring/curve.
FlattenTolerance
Maximum distance (model units) between a curve and its flattened polyline.
ModelTolerance
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].
PointShape
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).
ScreenTolerance
A screen-space tolerance in CSS pixels (pick radius, snap radius).
Segment
A straight line segment from a to b.
SubPath
One subpath of a Path decomposed 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§

AnchorKind
Semantic anchor kinds, used by snapping and constraints.
Curve
One elementary curve piece. Shapes decompose into these for intersections, trimming, hit-testing and tessellation.
GeometryError
Errors produced by geometry operations.
HAlign
Horizontal text alignment.
LinearKind
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.
ShapeKind
Shape kinds.
TransformPolicy
How to handle transforms that a shape cannot represent exactly.
VAlign
Vertical text alignment.

Constants§

MAX_SHAPE_POINTS
Limits enforced by Shape::validate to 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, None when 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 robust crate).
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.