Expand description
Independent analytic geometry using f64 coordinates in a caller-defined Cartesian plane.
Lengths use caller units, areas use squared units, and angles are radians,
positive counterclockwise from +x. Rings close implicitly without a repeated
first vertex. Tolerances are explicit; display tessellation is not a measurement
source. Enable schemars for JSON Schema generation. Serde support is always available.
use cadkit_geom::{GeometryTolerance, LineSegment, Point2};
let segment = LineSegment { start: Point2::new(0.0, 0.0), end: Point2::new(4.0, 0.0) };
let offset = segment.offset(1.0, &GeometryTolerance::default())?;
assert_eq!(offset.start, Point2::new(0.0, 1.0));Structs§
- Arc
- Circular arc in caller coordinates. Angles are radians from +x, counterclockwise for positive sweep, with at most one turn.
- Bezier
- Polynomial Bezier curve of degree 1-3 in caller coordinates, using a normalized parameter in 0-1 and explicit operation tolerances.
- Boolean
Boundary Provenance - Output polygon/ring reference and edge provenance in the boolean result’s coordinate system.
- Boolean
Diagnostics - Measured displacements and conservative error bounds in caller units, areas in squared units, plus dimensionless resource counts.
- Boolean
Edge Provenance - Output edge index and all contributing source spans; indices retain ring order and deviations use caller units.
- Boolean
Source Edge - Reference into the original boolean call’s operand, polygon, ring and edge order; indices are dimensionless and zero-based.
- Boolean
Source Span - Directed interval on a source edge. Parameters are dimensionless in 0-1, and deviation uses caller coordinate units.
- Bounds2
- Inclusive axis-aligned Cartesian bounds in caller units, with no implicit tolerance padding.
- Calibration
Fit - Least-squares transform and residuals in target coordinate units. Fitting and residual acceptance are separate operations.
- Circle
- Circle in caller coordinates with a positive radius greater than the supplied linear tolerance.
- Contact
Normalization - Measured normalization budget and changes, in caller coordinate units unless stated otherwise.
- Control
Point - A source-to-target Cartesian control pair, expressed in the units of the respective coordinate systems.
- Curve
Intersection Point - Intersection in caller coordinates with dimensionless parameters on both source curves and an explicit contact classification.
- Curve
Overlap - Positive-length overlapping curves and isolated contacts in caller coordinates, classified using the supplied tolerance.
- Ellipse
- Affine ellipse center + axis_ucos(angle) + axis_vsin(angle). Axes use caller units; angle is in radians. Axes need not be perpendicular.
- Geometry
Diagnostic - Structured error context. Codes and field paths are stable; messages are English. Numerical units follow the failing operation.
- Geometry
Tolerance - Independent positive finite budgets: coordinate units for length, radians for angles, squared units for area. Defaults are numerical starting values, not physical accuracy guarantees.
- Line
Segment - Directed Cartesian line segment in caller units. Validation requires finite endpoints and length above the supplied linear tolerance.
- Multi
Polygon - Collection of polygons in the same caller coordinate system; empty collections represent zero area. Operations use explicit tolerances.
- Nearest
Point Options - Distance certification budget in caller units and an explicit dimensionless iteration limit.
- Nearest
Point Result - Nearest-point result in caller coordinates. The error bound certifies distance, not uniqueness or position accuracy.
- Nurbs
Curve - Rational degree 1-3 curve in caller coordinates, with positive weights and open clamped knots. Public parameters normalize the active knot interval to 0-1; tolerances are explicit.
- Nurbs
Tessellation - Display polyline in caller coordinates and a certified two-sided approximation bound; not a source for analytic measurement.
- Nurbs
Tessellation Options - NURBS approximation budget in coordinate units and explicit dimensionless resource limits.
- Point2
- A point in the caller’s Cartesian coordinate units. Construction is unchecked; validate before operations requiring finite values.
- Polygon
- Polygon rings close implicitly from last to first; do not repeat the first point. Winding is preserved. Area is absolute exterior area minus hole areas, in squared caller units. Operations take an explicit tolerance.
- Polygon
Boolean Options - Boolean error budgets in caller units and squared units, with dimensionless resource limits. Coordinate error must not exceed the supplied linear tolerance.
- Polygon
Boolean Result - Regularized area geometry, diagnostics and source provenance in caller coordinates; area is in squared units.
- Polyline
- Ordered Cartesian vertices in caller units. Closed paths close implicitly; validity depends on the operation’s supplied tolerance.
- Snap
Candidate - Snap point and query distance in caller coordinate units; no screen-space convention is imposed.
- Transform2
- Affine Cartesian transform: x’=m11x+m12y+tx, y’=m21x+m22y+ty. Linear coefficients are dimensionless; translation uses target units.
- Validated
Polygon - Validated polygon query view retaining its coordinate system and tolerance. Location matches Polygon::locate; y bands select only segments near the boundary tolerance or horizontal ray.
- Vector2
- Cartesian displacement in caller units. Raw arithmetic is unchecked and applies no tolerance.
Enums§
- Boolean
Operand - Unit-independent identity of an input operand collection in a boolean call.
- Curve
- Analytic Cartesian curve in caller units. Angles are radians; operations explicitly validate their tolerance and supported profile.
- Curve
Intersection - Intersection result in caller coordinates. Points and overlaps are separate; unsupported pairs return an error.
- Geometry
Error - Invalid input or an unsupported operation; diagnostics retain the operation’s coordinate and tolerance context.
- Geometry
Reason - Stable, unit-independent reason codes; coordinate and tolerance context belongs to the diagnostic’s operation.
- Intersection
Kind - Unit-independent intersection classification using the operation’s linear and angular tolerances.
- Offset
Join - Join policy for signed offsets in caller coordinate units. Positive offsets lie left of the directed path; limits are explicit.
- Point
Location - Unit-independent relation to a polygon; boundary classification uses the operation’s linear tolerance.
- Polygon
Boolean Operation - Regularized area operation using caller-coordinate and squared-area error budgets; each operand collection represents a union.
- Polygon
Ring - Unit-independent ring reference into one polygon; hole indices preserve input order.
- Segment
Intersection - Segment intersection classified with the supplied linear and angular tolerance, in caller coordinates.
- Snap
Kind - Unit-independent classification of an analytic snap candidate; selection and display thresholds belong to the caller.
Functions§
- contact_
roundoff_ budget - Four ulps of the largest coordinate magnitude, with scale at least 1. The result uses coordinate units and only measures roundoff; it is not an application tolerance.
- evaluate_
calibration - Evaluate a nonsingular transform on nonempty control pairs; residuals use target units. Does not accept or reject a residual threshold automatically.
- finite
- Reject NaN and infinities without changing the scalar or its units; no tolerance is applied.
- fit_
affine - Fit an affine least-squares transform to at least three independent source pairs. Residuals use target coordinate units; angular tolerance controls conditioning.
- fit_
similarity - Fit an orientation-preserving least-squares similarity in caller coordinates. Use affine fitting when reflection is required; tolerances use source units and radians.
- grid_
snap - Round to the nearest grid coordinate relative to origin, using positive spacing in caller units. Halfway cases round away from zero relative to the grid; no tolerance is applied.
- normalize_
contacts - Join endpoint and edge contacts within an explicit coordinate-unit budget. Earlier vertices win, so place geometry to preserve first. Larger gaps remain untouched. Default boolean limits bound input and generated nodes. Nodes within budget of each other or an endpoint are deduplicated. Tolerances use the same coordinates.
- normalize_
contacts_ with_ spacing - Normalize contacts with an explicit minimum node spacing in coordinate units. A node closer than spacing to a neighbor or endpoint is not inserted. Using tolerance.linear prevents newly inserted edges below that tolerance; unresolved contacts remain for the boolean kernel to classify.
- polygon_
boolean - Each operand collection represents a union; overlapping clips are subtracted only once. Coordinates and linear budgets use caller units; area budgets use squared units.
- polygon_
slice - Split closed regions with zero-width separators without consuming area. Open ends do not close a region; output pieces are checked against area and coordinate budgets in the caller’s units.
- positive
- Require a finite, strictly positive scalar in its original units. The label appears in the English error message; no tolerance is applied.
- signed_
ring_ area - Compute signed shoelace area in squared caller units; counterclockwise is positive. Requires at least three finite vertices, closes implicitly and does not validate topology or apply tolerance.
Type Aliases§
- Geometry
Result - Result of an operation in caller-defined coordinates, carrying a typed diagnostic on failure.