pub struct Circle3D { /* private fields */ }Expand description
A 3D circle defined by center, normal (axis), and radius.
Parameterized as P(t) = center + radius*(cos(t)*u + sin(t)*v)
where u and v form an orthonormal basis in the circle plane.
t ranges from 0 to 2π for a full circle.
Implementations§
Source§impl Circle3D
impl Circle3D
Sourcepub fn new_with_ref(
center: Point3,
normal: Vec3,
radius: f64,
ref_dir: Vec3,
) -> Result<Self, MathError>
pub fn new_with_ref( center: Point3, normal: Vec3, radius: f64, ref_dir: Vec3, ) -> Result<Self, MathError>
Create a new circle with a caller-supplied reference x-direction.
ref_dir is projected onto the plane perpendicular to normal to
produce u_axis. Circles are radially symmetric so the choice of
u_axis has no geometric effect — but it does fix the seam vertex
at evaluate(0.0), which downstream code (closed-edge construction,
PCurve computation) can depend on.
§Errors
Returns an error if radius is non-positive or normal is zero.
Sourcepub fn circumference(&self) -> f64
pub fn circumference(&self) -> f64
The circle circumference.
Sourcepub fn project(&self, point: Point3) -> f64
pub fn project(&self, point: Point3) -> f64
Project a point onto the circle, returning the angle parameter.
Sourcepub fn with_axes(
center: Point3,
normal: Vec3,
radius: f64,
u_axis: Vec3,
v_axis: Vec3,
) -> Result<Self, MathError>
pub fn with_axes( center: Point3, normal: Vec3, radius: f64, u_axis: Vec3, v_axis: Vec3, ) -> Result<Self, MathError>
Create a circle with explicit basis vectors (for transform/copy).
§Errors
Returns an error if radius is non-positive.
Sourcepub fn intersect_segment(
&self,
seg_start: Point3,
seg_end: Point3,
tol: f64,
) -> Vec<(Point3, f64)>
pub fn intersect_segment( &self, seg_start: Point3, seg_end: Point3, tol: f64, ) -> Vec<(Point3, f64)>
Intersect the circle with a 3D line segment.
Returns up to 2 intersection points along with their angle parameter
t on the circle. Points returned are restricted to the segment
[seg_start, seg_end] (with tol slack on the endpoints).
Cases:
- Segment crosses the circle’s plane at one point: at most 1
intersection (when that crossing is on the circle, within
tol). - Segment lies in the circle’s plane: up to 2 intersections.
- Segment is parallel to the plane but offset: 0 intersections.
tol is the absolute linear tolerance for “on the plane” and
“on the circle” tests, and for clamping the segment parameter.
Sourcepub fn intersect_circle(&self, other: &Self, tol: f64) -> Vec<(Point3, f64)>
pub fn intersect_circle(&self, other: &Self, tol: f64) -> Vec<(Point3, f64)>
Intersect the circle with another COPLANAR circle.
Returns up to 2 intersection points along with their angle parameter
t on self. Non-coplanar pairs (skew or offset planes) and
coincident/concentric pairs return no points — callers own those
configurations separately.
Near-tangent conditioning: when the circles graze (the chord implied
by the root pair penetrates by less than tol), the two roots are
noise straddling the tangency foot — position error grows as
sqrt(2·r·δ), the recurring tangential-contact class. The
well-conditioned double root (the foot on the center line) is emitted
instead of the pair.