pub struct Spherical<const N: usize> { /* private fields */ }Expand description
Point on the surface of a sphere.
Spherical is a point on a unit N-sphere embedded in (N+1)-dimensional
euclidean space. Explicitly, the N-sphere is defined by the set of
(N+1)-dimensional points whose components satisfy
x_1^2 + x_2^2 + \cdots + x_{N+1}^1 = 1.0Note that the radius is fixed to be 1.0.
Implementations§
Source§impl<const N: usize> Spherical<N>
impl<const N: usize> Spherical<N>
Sourcepub fn coordinates(&self) -> &[f64; N]
pub fn coordinates(&self) -> &[f64; N]
Get the coordinates of the point
Sourcepub fn from_cartesian_coordinates(point: Cartesian<N>) -> Spherical<N>
pub fn from_cartesian_coordinates(point: Cartesian<N>) -> Spherical<N>
Construct a Sphere given a Cartesian vector and a radius.
§Panics
Panics when the point is not sufficiently close to the sphere’s surface.
Sourcepub fn stereographic_projection(&self) -> Vec<f64>
pub fn stereographic_projection(&self) -> Vec<f64>
Implements a stereographic projection from the N-sphere to an N-dimensional plane.
§Example
use hoomd_manifold::Spherical;
use hoomd_vector::Cartesian;
let x = Cartesian::from([0.5_f64.sqrt(), 0.0, -(0.5_f64.sqrt())]);
let projection =
Spherical::from_cartesian_coordinates(x).stereographic_projection();
assert_eq!(
[1.0 / (2.0_f64.sqrt() + 1.0), 0.0],
[projection[0], projection[1]]
);Trait Implementations§
Source§impl<const N: usize> AbsDiffEq for Spherical<N>
impl<const N: usize> AbsDiffEq for Spherical<N>
Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq].Source§impl<'de, const N: usize> Deserialize<'de> for Spherical<N>
impl<'de, const N: usize> Deserialize<'de> for Spherical<N>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Distribution<Spherical<3>> for SphericalDisk
impl Distribution<Spherical<3>> for SphericalDisk
Source§fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Spherical<3>
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Spherical<3>
T, using rng as the source of randomness.§fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>where
R: Rng,
Self: Sized,
fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>where
R: Rng,
Self: Sized,
T, using rng as
the source of randomness. Read moreSource§impl Metric for Spherical<3>
impl Metric for Spherical<3>
Source§fn distance(&self, other: &Self) -> f64
fn distance(&self, other: &Self) -> f64
The distance between two Spherical<3> points.
Explicitly, the metric for two points $\vec{u}$ and $\vec{v}$ on a
2-sphere with radius $R$ is given by
d_{S_2}(\vec{u}, \vec{v}) = R \arccos\left[\frac{1}{R^2}(u_1v_1 + u_2v_2 + u_3v_3)\right]This choice of metric furnishes a representation of 2-dimensional spherical
space with Gaussian curvature $K = 1/R^2$.
Source§fn distance_squared(&self, other: &Self) -> f64
fn distance_squared(&self, other: &Self) -> f64
Source§fn n_dimensions(&self) -> usize
fn n_dimensions(&self) -> usize
Source§impl Metric for Spherical<4>
impl Metric for Spherical<4>
Source§fn distance(&self, other: &Self) -> f64
fn distance(&self, other: &Self) -> f64
The distance between two Spherical<4> points.
Explicitly, the
metric for two points $\vec{u}$ and $\vec{v}$ on a 3-sphere with
radius $R$ is given by
d_{S_3}(\vec{u}, \vec{v}) = R \arccos\left[\frac{1}{R^2}(u_1v_1 + u_2v_2 + u_3v_3 + u_4v_4)\right]This choice of metric furnishes a representation of 3-dimensional spherical
space with Gaussian curvature $K = 1/R^2$.
Source§fn distance_squared(&self, other: &Self) -> f64
fn distance_squared(&self, other: &Self) -> f64
Source§fn n_dimensions(&self) -> usize
fn n_dimensions(&self) -> usize
Source§impl<const N: usize> RelativeEq for Spherical<N>
impl<const N: usize> RelativeEq for Spherical<N>
Source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
Source§fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
RelativeEq::relative_eq].