Sphere

Struct Sphere 

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

Sphere sequence generator

The Sphere struct is a generator for a sequence of points on a sphere.

Properties:

  • vdc: The vdc property is an instance of the VdCorput struct. It is used to generate a Van der Corput sequence, which is a low-discrepancy sequence used for sampling points in a unit interval.
  • cirgen: The cirgen property is an instance of the Circle struct. It is responsible for generating points on a circle.

§Examples

use lds_rs::Sphere;

let mut sgen = Sphere::new(&[2, 3]);
sgen.reseed(1);
let result = sgen.pop();
assert_eq!(result[2], -0.5);

Implementations§

Source§

impl Sphere

Source

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

Creates a new Sphere.

The function new creates a new Sphere object with a given base.

Arguments:

  • base: The base parameter is an array of usize values. It is used to initialize the Sphere struct. The first element of the base array is used to create a new VdCorput struct, and the second element is used to create a new `Circle

Returns:

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

Source

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

Returns the pop of this Sphere.

The pop function returns a random point on a sphere using the VDC and cirgen generators.

Returns:

an array of three f64 values, representing the coordinates of a point on a sphere. The first two values (sinphi * c and sinphi * s) represent the x and y coordinates, while the third value (cosphi) represents the z coordinate.

§Examples
use lds_rs::lds::Sphere;
use approx_eq::assert_approx_eq;

let mut sphere = Sphere::new(&[2, 3]);
let result = sphere.pop();
assert_approx_eq!(result[0], -0.5);
assert_approx_eq!(result[1], 0.8660254037844387);
assert_approx_eq!(result[2], 0.0);
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 Sphere

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Sphere

§

impl RefUnwindSafe for Sphere

§

impl Send for Sphere

§

impl Sync for Sphere

§

impl Unpin for Sphere

§

impl UnwindSafe for Sphere

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.