Skip to main content

SphericalSurface

Struct SphericalSurface 

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

An infinite spherical surface (actually a sphere).

Parameterized as P(u, v) = center + radius*(cos(v)*cos(u)*x + cos(v)*sin(u)*y + sin(v)*z) where u ∈ [0, 2π) (longitude) and v ∈ [-π/2, π/2] (latitude).

Implementations§

Source§

impl SphericalSurface

Source

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

Creates a new spherical surface.

§Errors

Returns an error if radius is not positive.

Source

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

Creates a spherical surface with a custom orientation.

§Errors

Returns an error if radius is not positive or the z-axis is zero.

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 normal at parameters (u, v).

Source

pub const fn center(&self) -> Point3

Returns the center.

Source

pub const fn radius(&self) -> f64

Returns the 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 local Z axis (pole direction).

Source

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

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

Source

pub fn aabb(&self) -> Aabb3

Axis-aligned bounding box of the full sphere (center ± radius on every axis). Orientation-independent and a sound superset of any spherical patch — the boolean broad-phase uses it because a face’s boundary-only bbox misses the surface bulge between its boundary edges (a hemisphere’s only boundary is its equator).

Source

pub fn aabb_region(&self, pole: Vec3) -> Aabb3

Axis-aligned bounding box of the hemisphere on the pole-axis side — the half-ball {center + radius·d : d·pole ≥ 0}. A tight, sound superset of any spherical patch lying on that side; the boolean broad-phase uses it so that one hemisphere face’s box does not admit the other’s sections (the full-sphere aabb would). Falls back to the full sphere when pole is degenerate (side ambiguous).

Source

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

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

u is the longitudinal angle [0, 2π), v is the latitude [-π/2, π/2].

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 SphericalSurface

Source§

fn clone(&self) -> SphericalSurface

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 SphericalSurface

Source§

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

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

impl<'de> Deserialize<'de> for SphericalSurface

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 SphericalSurface

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 SphericalSurface

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.