Add some comments about random variates

This commit is contained in:
Vinzent Steinberg 2021-04-10 03:20:30 -03:00
parent fd3a752409
commit c8fe49b1e9
6 changed files with 7 additions and 0 deletions

View File

@ -691,6 +691,7 @@ impl<N: RealField> Distribution<Orthographic3<N>> for Standard
where
Standard: Distribution<N>,
{
/// Generate an arbitrary random variate for testing purposes.
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> Orthographic3<N> {
use crate::base::helper;
let left = r.gen();

View File

@ -275,6 +275,7 @@ impl<N: RealField> Distribution<Perspective3<N>> for Standard
where
Standard: Distribution<N>,
{
/// Generate an arbitrary random variate for testing purposes.
fn sample<'a, R: Rng + ?Sized>(&self, r: &'a mut R) -> Perspective3<N> {
use crate::base::helper;
let znear = r.gen();

View File

@ -164,6 +164,7 @@ where
DefaultAllocator: Allocator<N, D>,
Standard: Distribution<N>,
{
/// Generate a `Point` where each coordinate is an independent variate from `[0, 1)`.
#[inline]
fn sample<'a, G: Rng + ?Sized>(&self, rng: &mut G) -> Point<N, D> {
Point::from(rng.gen::<VectorN<N, D>>())

View File

@ -69,6 +69,7 @@ where
DefaultAllocator: Allocator<N, D>,
Standard: Distribution<N> + Distribution<R>,
{
/// Generate an arbitrary random variate for testing purposes.
#[inline]
fn sample<'a, G: Rng + ?Sized>(&self, rng: &mut G) -> Similarity<N, D, R> {
let mut s = rng.gen();

View File

@ -78,6 +78,7 @@ where
DefaultAllocator: Allocator<N, D>,
Standard: Distribution<N>,
{
/// Generate an arbitrary random variate for testing purposes.
#[inline]
fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> Translation<N, D> {
Translation::from(rng.gen::<VectorN<N, D>>())

View File

@ -33,6 +33,8 @@ where
// This is a wrapper similar to RandComplex, but for non-complex.
// This exists only to make generic tests easier to write.
//
// Generates variates in the range [0, 1).
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct RandScalar<N>(pub N);