Skip to main content

Circle3D

Struct Circle3D 

Source
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

Source

pub fn new(center: Point3, normal: Vec3, radius: f64) -> Result<Self, MathError>

Create a new circle.

§Errors

Returns an error if radius is non-positive or normal is zero.

Source

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.

Source

pub fn evaluate(&self, t: f64) -> Point3

Evaluate the circle at angle t (radians).

Source

pub fn tangent(&self, t: f64) -> Vec3

Tangent at angle t (unit-length).

Source

pub fn circumference(&self) -> f64

The circle circumference.

Source

pub const fn center(&self) -> Point3

The circle center.

Source

pub const fn radius(&self) -> f64

The circle radius.

Source

pub const fn normal(&self) -> Vec3

The circle normal (axis direction).

Source

pub fn project(&self, point: Point3) -> f64

Project a point onto the circle, returning the angle parameter.

Source

pub const fn u_axis(&self) -> Vec3

The u-axis direction (major axis in the circle plane).

Source

pub const fn v_axis(&self) -> Vec3

The v-axis direction (minor axis in the circle plane).

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Circle3D

Source§

fn clone(&self) -> Circle3D

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Circle3D

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Circle3D

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl ParametricCurve for Circle3D

Source§

fn evaluate(&self, t: f64) -> Point3

Evaluate the curve at parameter t.
Source§

fn tangent(&self, t: f64) -> Vec3

Tangent vector at parameter t.
Source§

fn domain(&self) -> (f64, f64)

Parameter domain as (t_min, t_max).
Source§

impl Serialize for Circle3D

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.