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
impl SphereAtlas
Sourcepub fn of_surface(surface: &NurbsSurface) -> Option<Self>
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.
pub fn of_analytic(analytic: &AnalyticSurface) -> Option<Self>
Sourcepub fn chart(&self, index: usize) -> Chart
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.
Sourcepub fn direction(&self, chart: usize, s: f64, t: f64) -> Vec3
pub fn direction(&self, chart: usize, s: f64, t: f64) -> Vec3
Unnormalized chart direction — the point of the cube face itself.
Sourcepub fn point(&self, chart: usize, s: f64, t: f64) -> Result<Vec3, String>
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.
Sourcepub fn normal_at(&self, chart: usize, s: f64, t: f64) -> Result<Vec3, String>
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.
Sourcepub fn parameterization_is_outward(
&self,
surface: &NurbsSurface,
) -> Result<bool, String>
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.
Sourcepub fn axis_coordinates(&self, point: Vec3) -> [f64; 3]
pub fn axis_coordinates(&self, point: Vec3) -> [f64; 3]
Basis coordinates of point relative to the centre.
Sourcepub fn locate(&self, point: Vec3) -> usize
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.
Sourcepub fn coordinates(&self, chart: usize, point: Vec3) -> Option<(f64, f64)>
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.
Sourcepub fn contains(&self, chart: usize, point: Vec3) -> bool
pub fn contains(&self, chart: usize, point: Vec3) -> bool
Whether point lies in chart’s closed square, within a relative slack.
Sourcepub fn charts_containing(&self, point: Vec3) -> Vec<usize>
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.
Sourcepub fn edge_of(
&self,
point: Vec3,
relative_tolerance: f64,
) -> Option<(usize, f64)>
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.
Sourcepub fn edges_containing(
&self,
point: Vec3,
relative_tolerance: f64,
) -> Vec<(usize, f64)>
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.
Sourcepub fn edge_point(&self, edge: usize, q: f64) -> Result<Vec3, String>
pub fn edge_point(&self, edge: usize, q: f64) -> Result<Vec3, String>
The sphere point on cube edge edge at edge parameter q.
Sourcepub fn arc_chart_crossings(&self, start: Vec3, end: Vec3) -> Vec<f64>
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.
Sourcepub fn split_polyline(
&self,
points: &[Vec3],
) -> Result<Vec<ChartSegment>, String>
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.
Sourcepub fn split_segment(
&self,
start: Vec3,
end: Vec3,
) -> Result<Vec<ChartSegment>, String>
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
impl Clone for SphereAtlas
Source§fn clone(&self) -> SphereAtlas
fn clone(&self) -> SphereAtlas
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more