Sphere3Hopf

Struct Sphere3Hopf 

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

The Sphere3Hopf struct is a sequence generator for the S(3) sequence using Hopf coordinates.

Properties:

  • vdc0: An instance of the VdCorput sequence generator used for the first coordinate of the Hopf coordinates.
  • vdc1: The vdc1 property is an instance of the VdCorput struct, which is used to generate a Van der Corput sequence. This sequence is a low-discrepancy sequence that is commonly used in numerical methods for generating random numbers. In this case, it is
  • vdc2: The vdc2 property is an instance of the VdCorput struct, which is used to generate a Van der Corput sequence. This sequence is a low-discrepancy sequence that is commonly used in numerical methods for generating random numbers. In the context of the `

The Sphere3Hopf class is a sequence generator that generates points on a 3-sphere using the Hopf fibration. It uses three instances of the VdCorput class to generate the sequence values and maps them to points on the 3-sphere. The pop() method returns the next point on the 3-sphere as a [f64; 4], where the first three elements represent the x, y, and z coordinates of the point, and the fourth element represents the w coordinate. The reseed() method is used to reset the state of the sequence generator to a specific seed value.

§Examples

use lds_rs::Sphere3Hopf;
use approx_eq::assert_approx_eq;

let mut sgen = Sphere3Hopf::new(&[2, 3, 5]);
sgen.reseed(0);
let result = sgen.pop();
assert_approx_eq!(result[2], 0.4472135954999573);

Implementations§

Source§

impl Sphere3Hopf

Source

pub fn new(base: &[usize]) -> Self

Creates a new Sphere3Hopf.

The new function creates a new instance of the Sphere3Hopf struct with three VdCorput instances initialized with the values from the base slice.

Arguments:

  • base: The base parameter is an array of three usize values. These values are used to initialize three instances of the VdCorput struct, which is a type of quasi-random number generator. Each VdCorput instance is initialized with a different base value from the

Returns:

The new function is returning an instance of the Sphere3Hopf struct.

Source

pub fn pop(&mut self) -> [f64; 4]

The pop function returns a four-element array representing the coordinates of a point on a sphere in 3D space.

Returns:

The function pop returns an array of four f64 values. Returns the pop of this Sphere3Hopf.

The pop() function is used to generate the next value in the sequence. For example, in the VdCorput class, pop() increments the count and calculates the Van der Corput sequence value for that count and base. In the Disk class, pop() returns the next point in the Disk sequence as a [f64; 2]. Similarly, in the Circle class, pop() returns the next point on the unit circle as a [f64; 2]. In the Sphere class, pop() returns the next point on the unit sphere as a [f64; 3]. And in the Sphere3Hopf class, pop() returns the next point on the 3-sphere using the Hopf fibration as a [f64; 4].

§Examples
use lds_rs::Sphere3Hopf;
use approx_eq::assert_approx_eq;

let mut sgen = Sphere3Hopf::new(&[2, 3, 5]);
let result = sgen.pop();
assert_approx_eq!(result[2], 0.4472135954999573);
Source

pub fn reseed(&mut self, seed: usize)

The below code is a Rust function called reseed that is used to reset the state of a sequence generator to a specific seed value. This allows the sequence generator to start generating the sequence from the beginning or from a specific point in the sequence, depending on the value of the seed.

Trait Implementations§

Source§

impl Debug for Sphere3Hopf

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> 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, 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.