Skip to main content

Crate cadkit_geom

Crate cadkit_geom 

Source
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.
BooleanBoundaryProvenance
Output polygon/ring reference and edge provenance in the boolean result’s coordinate system.
BooleanDiagnostics
Measured displacements and conservative error bounds in caller units, areas in squared units, plus dimensionless resource counts.
BooleanEdgeProvenance
Output edge index and all contributing source spans; indices retain ring order and deviations use caller units.
BooleanSourceEdge
Reference into the original boolean call’s operand, polygon, ring and edge order; indices are dimensionless and zero-based.
BooleanSourceSpan
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.
CalibrationFit
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.
ContactNormalization
Measured normalization budget and changes, in caller coordinate units unless stated otherwise.
ControlPoint
A source-to-target Cartesian control pair, expressed in the units of the respective coordinate systems.
CurveIntersectionPoint
Intersection in caller coordinates with dimensionless parameters on both source curves and an explicit contact classification.
CurveOverlap
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.
GeometryDiagnostic
Structured error context. Codes and field paths are stable; messages are English. Numerical units follow the failing operation.
GeometryTolerance
Independent positive finite budgets: coordinate units for length, radians for angles, squared units for area. Defaults are numerical starting values, not physical accuracy guarantees.
LineSegment
Directed Cartesian line segment in caller units. Validation requires finite endpoints and length above the supplied linear tolerance.
MultiPolygon
Collection of polygons in the same caller coordinate system; empty collections represent zero area. Operations use explicit tolerances.
NearestPointOptions
Distance certification budget in caller units and an explicit dimensionless iteration limit.
NearestPointResult
Nearest-point result in caller coordinates. The error bound certifies distance, not uniqueness or position accuracy.
NurbsCurve
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.
NurbsTessellation
Display polyline in caller coordinates and a certified two-sided approximation bound; not a source for analytic measurement.
NurbsTessellationOptions
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.
PolygonBooleanOptions
Boolean error budgets in caller units and squared units, with dimensionless resource limits. Coordinate error must not exceed the supplied linear tolerance.
PolygonBooleanResult
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.
SnapCandidate
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.
ValidatedPolygon
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§

BooleanOperand
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.
CurveIntersection
Intersection result in caller coordinates. Points and overlaps are separate; unsupported pairs return an error.
GeometryError
Invalid input or an unsupported operation; diagnostics retain the operation’s coordinate and tolerance context.
GeometryReason
Stable, unit-independent reason codes; coordinate and tolerance context belongs to the diagnostic’s operation.
IntersectionKind
Unit-independent intersection classification using the operation’s linear and angular tolerances.
OffsetJoin
Join policy for signed offsets in caller coordinate units. Positive offsets lie left of the directed path; limits are explicit.
PointLocation
Unit-independent relation to a polygon; boundary classification uses the operation’s linear tolerance.
PolygonBooleanOperation
Regularized area operation using caller-coordinate and squared-area error budgets; each operand collection represents a union.
PolygonRing
Unit-independent ring reference into one polygon; hole indices preserve input order.
SegmentIntersection
Segment intersection classified with the supplied linear and angular tolerance, in caller coordinates.
SnapKind
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§

GeometryResult
Result of an operation in caller-defined coordinates, carrying a typed diagnostic on failure.