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
impl ToroidalSurface
Sourcepub fn new(
center: Point3,
major_radius: f64,
minor_radius: f64,
) -> Result<Self, MathError>
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.
Sourcepub fn with_axis(
center: Point3,
major_radius: f64,
minor_radius: f64,
z_axis: Vec3,
) -> Result<Self, MathError>
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.
Sourcepub fn with_axis_and_ref_dir(
center: Point3,
major_radius: f64,
minor_radius: f64,
z_axis: Vec3,
ref_dir: Vec3,
) -> Result<Self, MathError>
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).
Sourcepub fn normal(&self, u: f64, v: f64) -> Vec3
pub fn normal(&self, u: f64, v: f64) -> Vec3
Returns the outward surface normal at parameters (u, v).
Sourcepub fn translated(&self, offset: Vec3) -> Self
pub fn translated(&self, offset: Vec3) -> Self
Returns a copy of this torus with its center translated by offset.
Sourcepub fn aabb(&self) -> Aabb3
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.
Sourcepub const fn major_radius(&self) -> f64
pub const fn major_radius(&self) -> f64
Returns the major radius (distance from center to tube center).
Sourcepub const fn minor_radius(&self) -> f64
pub const fn minor_radius(&self) -> f64
Returns the minor radius (tube cross-section radius).
Sourcepub const fn z_axis(&self) -> Vec3
pub const fn z_axis(&self) -> Vec3
Returns the torus axis direction (perpendicular to the ring plane).
Sourcepub fn project_point(&self, point: Point3) -> (f64, f64)
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.
Trait Implementations§
Source§impl Clone for ToroidalSurface
impl Clone for ToroidalSurface
Source§fn clone(&self) -> ToroidalSurface
fn clone(&self) -> ToroidalSurface
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more