Skip to main content

SphereAtlas

Struct SphereAtlas 

Source
pub struct SphereAtlas {
    pub centre: Vec3,
    pub radius: f64,
    pub basis: [Vec3; 3],
}
Expand description

A sphere’s pole-free cube atlas: centre, radius, and the right-handed basis the six charts are built on.

Fields§

§centre: Vec3§radius: f64§basis: [Vec3; 3]

basis[2] is the polar axis, so the two degenerate poles of the stored polar domain sit at the centres of charts 4 and 5.

Implementations§

Source§

impl SphereAtlas

Source

pub fn of_surface(surface: &NurbsSurface) -> Option<Self>

The atlas of a surface that IS a sphere, however it is parameterized.

Routed through AnalyticSurface::sphere_frame, so a REFLECTED sphere — which recognizes as a general Revolution, not as Sphere — gets an atlas exactly as a direct one does. Matching on the Sphere variant here would silently drop every mirrored ball.

Source

pub fn of_analytic(analytic: &AnalyticSurface) -> Option<Self>

Source

pub fn chart(&self, index: usize) -> Chart

Chart index: axis = index / 2, facing + for even and - for odd.

The tangents are picked so tangent_s × tangent_t = normal for all six, which makes every chart’s ∂p/∂s × ∂p/∂t point out of the sphere — the atlas has ONE orientation, so a triangle wound counter-clockwise in any chart faces outward in every other.

Source

pub fn direction(&self, chart: usize, s: f64, t: f64) -> Vec3

Unnormalized chart direction — the point of the cube face itself.

Source

pub fn point(&self, chart: usize, s: f64, t: f64) -> Result<Vec3, String>

The sphere point at chart coordinates (s, t). Exact: the result lies on the sphere to the accuracy of one normalize.

Source

pub fn normal_at(&self, chart: usize, s: f64, t: f64) -> Result<Vec3, String>

Outward unit normal at chart coordinates (s, t) — for a sphere the normal IS the radial direction, so no derivative is ever needed and there is no pole at which one degenerates.

Source

pub fn parameterization_is_outward( &self, surface: &NurbsSurface, ) -> Result<bool, String>

Whether the surface’s OWN Su x Sv points out of the sphere, sampled at the middle of its parameter domain — for a polar sphere the equator, as far from either degenerate pole as the domain allows.

The trim convention (material to the LEFT of the directed boundary) is stated against this normal, not against the face’s sense, and a reflected sphere has it pointing inward — so no consumer may assume it.

Source

pub fn axis_coordinates(&self, point: Vec3) -> [f64; 3]

Basis coordinates of point relative to the centre.

Source

pub fn locate(&self, point: Vec3) -> usize

The chart a point belongs to when only one answer is wanted: the chart whose face the point projects furthest onto, lowest index breaking a tie. Deterministic, so it can be used as a key.

Source

pub fn coordinates(&self, chart: usize, point: Vec3) -> Option<(f64, f64)>

Chart coordinates of point in chart, or None when the point is on the far side of the sphere from it. A point outside the chart’s square still returns coordinates (with |s| > 1 or |t| > 1); use Self::contains to ask about membership.

Source

pub fn contains(&self, chart: usize, point: Vec3) -> bool

Whether point lies in chart’s closed square, within a relative slack.

Source

pub fn charts_containing(&self, point: Vec3) -> Vec<usize>

Every chart whose closed square contains point: one in a chart interior, two on a cube edge, three at a corner. Ascending index, so the answer is order-independent.

Source

pub fn edge_of( &self, point: Vec3, relative_tolerance: f64, ) -> Option<(usize, f64)>

The cube edge point lies on, with its edge parameter q, or None when the point is in a chart interior.

A point sits on a cube edge exactly when the two LARGEST of its three basis coordinates are equal in magnitude; q is the third coordinate scaled so those two are ±1. Returning q — rather than either chart’s own coordinate — is what lets a crossing be filed against the edge once and read back by both charts.

Source

pub fn edges_containing( &self, point: Vec3, relative_tolerance: f64, ) -> Vec<(usize, f64)>

EVERY cube edge point lies on: one along an edge, three at a corner, none in a chart interior.

Callers that have to decide whether two points share an edge must use this rather than Self::edge_of: a corner lies on three edges at once, and picking one of them canonically would make a segment running INTO a corner look as if it left the edge it is on.

Source

pub fn edge_point(&self, edge: usize, q: f64) -> Result<Vec3, String>

The sphere point on cube edge edge at edge parameter q.

Source

pub fn arc_chart_crossings(&self, start: Vec3, end: Vec3) -> Vec<f64>

The parameters λ ∈ (0, 1) at which the great-circle arc from start to end crosses a chart boundary, ascending.

A chart boundary is one of the six planes |x_i| = |x_j| through the centre, so the crossing is the root of a function that is LINEAR along the chord — no Newton iteration, no seeding, and nothing that could converge onto an extrapolated surface. λ interpolates the chord (1−λ)·d_start + λ·d_end; the crossing point is that direction normalized back onto the sphere, which is exactly where the arc meets the plane.

The result depends only on the two endpoints, never on which chart is asking, so both charts sharing the crossing derive the identical point. A plane crossed AWAY from the cube edge it carries (the other coordinate is larger there) is not a chart boundary at that point and is dropped.

Source

pub fn split_polyline( &self, points: &[Vec3], ) -> Result<Vec<ChartSegment>, String>

Split a closed polyline on the sphere so that no segment crosses a chart boundary, returning (point, chart) for every segment: the vertices of the segment and the single chart it lies in.

Crossing points are inserted at the exact positions Self::arc_chart_crossings reports, so a vertex on a cube edge belongs to both adjacent charts with identical coordinates.

Source

pub fn split_segment( &self, start: Vec3, end: Vec3, ) -> Result<Vec<ChartSegment>, String>

Self::split_polyline for ONE segment. A caller holding individual boundary segments must use this: handing a two-point slice to the polyline form would close it and emit the segment twice, once each way.

Trait Implementations§

Source§

impl Clone for SphereAtlas

Source§

fn clone(&self) -> SphereAtlas

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 Copy for SphereAtlas

Source§

impl Debug for SphereAtlas

Source§

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

Formats the value using the given formatter. 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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more