Skip to main content

ToroidalSurface

Struct ToroidalSurface 

Source
pub struct ToroidalSurface { /* private fields */ }
Expand description

A toroidal surface.

Parameterized as P(u, v) = center + (R + r*cos(v))*(cos(u)*x + sin(u)*y) + r*sin(v)*z where R is the major radius, r is the minor radius, u ∈ [0, 2π) (around the tube) and v ∈ [0, 2π) (around the cross-section).

Implementations§

Source§

impl ToroidalSurface

Source

pub fn new( center: Point3, major_radius: f64, minor_radius: f64, ) -> Result<Self, MathError>

Creates a new toroidal surface.

§Errors

Returns an error if either radius is not positive or minor_radius > major_radius.

Source

pub fn with_axis( center: Point3, major_radius: f64, minor_radius: f64, z_axis: Vec3, ) -> Result<Self, MathError>

Creates a toroidal surface with a specified axis direction.

The axis is the central symmetry axis of the torus. The local coordinate frame is derived from it.

§Errors

Returns an error if either radius is not positive or axis is zero.

Source

pub fn with_axis_and_ref_dir( center: Point3, major_radius: f64, minor_radius: f64, z_axis: Vec3, ref_dir: Vec3, ) -> Result<Self, MathError>

Create a torus with explicit axis and reference direction.

ref_dir defines the x-axis of the local frame (projected perpendicular to z_axis). This preserves the parametric orientation from STEP AXIS2_PLACEMENT_3D.

§Errors

Returns MathError::ParameterOutOfRange if either radius is non-positive, or MathError::ZeroVector if z_axis is zero.

§Panics

Panics if the fallback perpendicular vector cannot be normalized (should not occur for any valid unit z_axis).

Source

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

Evaluates the surface at parameters (u, v).

Source

pub fn normal(&self, u: f64, v: f64) -> Vec3

Returns the outward surface normal at parameters (u, v).

Source

pub const fn center(&self) -> Point3

Returns the center.

Source

pub fn translated(&self, offset: Vec3) -> Self

Returns a copy of this torus with its center translated by offset.

Source

pub fn aabb(&self) -> Aabb3

Axis-aligned bounding box of the full torus. The half-extent along each world axis sums the ring’s projection onto the plane perpendicular to the torus axis ((major+minor)·‖(x·ê, y·ê)‖) and the tube’s projection onto the axis (minor·|z·ê|); x/y/z_axis are orthonormal. A sound superset used by the boolean broad-phase — a full torus’s boundary is degenerate seam points, so a boundary-only bbox collapses to a point.

Source

pub const fn major_radius(&self) -> f64

Returns the major radius (distance from center to tube center).

Source

pub const fn minor_radius(&self) -> f64

Returns the minor radius (tube cross-section radius).

Source

pub const fn x_axis(&self) -> Vec3

Returns the local X axis.

Source

pub const fn y_axis(&self) -> Vec3

Returns the local Y axis.

Source

pub const fn z_axis(&self) -> Vec3

Returns the torus axis direction (perpendicular to the ring plane).

Source

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

Project a 3D point onto the torus surface, returning (u, v) parameters.

u ∈ [0, 2π) is the angle around the major circle. v ∈ [0, 2π) is the angle around the tube cross-section.

Source

pub fn to_nurbs(&self) -> Result<NurbsSurface, MathError>

Convert to an approximate NURBS surface.

§Errors

Returns an error if NurbsSurface construction fails.

Trait Implementations§

Source§

impl Clone for ToroidalSurface

Source§

fn clone(&self) -> ToroidalSurface

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 ToroidalSurface

Source§

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

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

impl<'de> Deserialize<'de> for ToroidalSurface

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 ParametricSurface for ToroidalSurface

Source§

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

Evaluate the surface at parameters (u, v).
Source§

fn normal(&self, u: f64, v: f64) -> Vec3

Surface normal at parameters (u, v). Read more
Source§

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

Project a 3D point onto the surface, returning (u, v) parameters.
Source§

fn partial_u(&self, u: f64, v: f64) -> Vec3

Partial derivative ∂S/∂u at (u, v).
Source§

fn partial_v(&self, u: f64, v: f64) -> Vec3

Partial derivative ∂S/∂v at (u, v).
Source§

impl Serialize for ToroidalSurface

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.