Circle

Struct Circle 

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

Circle sequence generator

The Circle struct is a generator for a circle sequence using the Van der Corput sequence.

Properties:

  • vdc: A variable of type VdCorput, which is a sequence generator for Van der Corput sequence.

§Examples

use lds_rs::Circle;

let mut cgen = Circle::new(2);
cgen.reseed(1);
let result = cgen.pop();
assert_eq!(result[1], 1.0);

Implementations§

Source§

impl Circle

Source

pub fn new(base: usize) -> Self

Creates a new Circle.

The new function creates a new Circle object with a specified base value.

Arguments:

  • base: The base parameter in the new function is the base value used to generate the Van der Corput sequence. The Van der Corput sequence is a low-discrepancy sequence used in quasi-Monte Carlo methods. It is generated by reversing the digits of the fractional part of the

Returns:

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

Source

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

Returns the pop of this Circle.

The pop function returns the coordinates of a point on a circle based on a random value.

Returns:

The pop function returns an array of two f64 values, representing the sine and cosine of a randomly generated angle.

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

let mut circle = Circle::new(2);
let result = circle.pop();
assert_approx_eq!(result[1], 0.0);
assert_approx_eq!(result[0], -1.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 Circle

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Circle

§

impl RefUnwindSafe for Circle

§

impl Send for Circle

§

impl Sync for Circle

§

impl Unpin for Circle

§

impl UnwindSafe for Circle

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.