Spherical

Struct Spherical 

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

Note that the radius is fixed to be 1.0.

Implementations§

Source§

impl<const N: usize> Spherical<N>

Source

pub fn coordinates(&self) -> &[f64; N]

Get the coordinates of the point

Source

pub fn point(&self) -> &Cartesian<N>

Get the point of the sphere

Source

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.

Source

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]]
);
Source§

impl Spherical<3>

Source

pub fn from_polar_coordinates(theta: f64, phi: f64) -> Spherical<3>

Create a 2-sphere from spherical coordinates

Source§

impl Spherical<4>

Source

pub fn from_polar_coordinates( theta: f64, phi_1: f64, phi_2: f64, ) -> Spherical<4>

Create a 3-sphere from spherical coordinates

Trait Implementations§

Source§

impl<const N: usize> AbsDiffEq for Spherical<N>

Source§

type Epsilon = <Cartesian<N> as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool

A test for equality that uses the absolute difference to compute the approximimate equality of two numbers.
§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of [AbsDiffEq::abs_diff_eq].
Source§

impl<const N: usize> Clone for Spherical<N>

Source§

fn clone(&self) -> Spherical<N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize> Debug for Spherical<N>

Source§

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

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

impl<const N: usize> Default for Spherical<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de, const N: usize> Deserialize<'de> for Spherical<N>

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 Distribution<Spherical<3>> for SphericalDisk

Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Spherical<3>

Generate a random value of T, using rng as the source of randomness.
§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
§

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl Metric for Spherical<3>

Source§

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

Compute the squared distance between two vectors belonging to a metric space. Read more
Source§

fn n_dimensions(&self) -> usize

Return the number of dimensions in this vector space. Read more
Source§

impl Metric for Spherical<4>

Source§

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

Compute the squared distance between two vectors belonging to a metric space. Read more
Source§

fn n_dimensions(&self) -> usize

Return the number of dimensions in this vector space. Read more
Source§

impl<const N: usize> PartialEq for Spherical<N>

Source§

fn eq(&self, other: &Spherical<N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const N: usize> RelativeEq for Spherical<N>

Source§

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
Source§

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

The inverse of [RelativeEq::relative_eq].
Source§

impl<const N: usize> Serialize for Spherical<N>

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

impl<const N: usize> Copy for Spherical<N>

Source§

impl<const N: usize> StructuralPartialEq for Spherical<N>

Auto Trait Implementations§

§

impl<const N: usize> Freeze for Spherical<N>

§

impl<const N: usize> RefUnwindSafe for Spherical<N>

§

impl<const N: usize> Send for Spherical<N>

§

impl<const N: usize> Sync for Spherical<N>

§

impl<const N: usize> Unpin for Spherical<N>

§

impl<const N: usize> UnwindSafe for Spherical<N>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,