Struct lds_rs::lds::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[0], 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[0], 0.0);
assert_approx_eq!(result[1], -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
source§

impl PartialEq<Circle> for Circle

source§

fn eq(&self, other: &Circle) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Circle

source§

impl StructuralEq for Circle

source§

impl StructuralPartialEq for Circle

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.