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: Thevdc1property is an instance of theVdCorputstruct, 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 isvdc2: Thevdc2property is an instance of theVdCorputstruct, 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
impl Sphere3Hopf
Sourcepub fn new(base: &[usize]) -> Self
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: Thebaseparameter is an array of threeusizevalues. These values are used to initialize three instances of theVdCorputstruct, which is a type of quasi-random number generator. EachVdCorputinstance is initialized with a different base value from the
Returns:
The new function is returning an instance of the Sphere3Hopf struct.
Sourcepub fn pop(&mut self) -> [f64; 4]
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);Sourcepub fn reseed(&mut self, seed: usize)
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.