pub struct Point {
pub x: f64,
pub y: f64,
}Expand description
A meaningful spacial coordinate.
Most transformations of this type return a Vector, that is not
bound to mean a location in space. Vectors can be converted back
into points if the programmer determines they again represent a
coordinate in space with Vector::p()
Fields§
§x: f64§y: f64Implementations§
Source§impl Point
impl Point
Sourcepub fn new(x: f64, y: f64) -> Self
pub fn new(x: f64, y: f64) -> Self
Create new point. This is just a helper given the fields are public.
Sourcepub fn close_to(&self, other: &Point, epsilon: f64) -> bool
pub fn close_to(&self, other: &Point, epsilon: f64) -> bool
Returns true of this point is within epsilon distance of other
uses euclidian squared distance internally for speed.
Sourcepub fn distance(&self, other: &Point) -> f64
pub fn distance(&self, other: &Point) -> f64
calulates the euclidian distance between this point and other
Sourcepub fn distance_2(&self, other: &Point) -> f64
pub fn distance_2(&self, other: &Point) -> f64
calulates the euclidian squared distance between this point and other
mostly useful as an optimisation to save the square root when comparing distnaces
Trait Implementations§
Source§impl<R> From<Point> for SamplerPoint<R>where
R: Rng,
A tuple of type (Sampler::<T>,Sampler<T>) will be interpreted as a uniform distribution if turned into a sampler.
impl<R> From<Point> for SamplerPoint<R>where
R: Rng,
A tuple of type (Sampler::<T>,Sampler<T>) will be interpreted as a uniform distribution if turned into a sampler.
§Example:
extern crate rand;
use rustic_zen::sampler::SamplerPoint;
use rustic_zen::sampler::Sampler;
use rand::prelude::*;
let mut r = rand::thread_rng();
// results in a rounds soft distribution, useful for area lights.
let _p: SamplerPoint<ThreadRng> = (Sampler::new_gaussian(0.0, 3.0), Sampler::new_gaussian(0.0, 3.0)).into();
This is the only way to construct a SamplerPoint. This shorthand can be extended using the Sampler’s into traits:
extern crate rand;
use rustic_zen::sampler::SamplerPoint;
use rustic_zen::geom::Point;
use rand::prelude::*;
let mut r = rand::thread_rng();
// results in a fixed point at 0.0, 0.0
let _p: SamplerPoint<ThreadRng> = (0.0, 0.0).into();
// results in a uniformly distributed square from 0.0, 0.0 to 10.0, 10.0
let _p: SamplerPoint<ThreadRng> = ((0.0, 10.0), (0.0, 10.0)).into();Source§impl PartialOrd for Point
impl PartialOrd for Point
impl Copy for Point
impl StructuralPartialEq for Point
Auto Trait Implementations§
impl Freeze for Point
impl RefUnwindSafe for Point
impl Send for Point
impl Sync for Point
impl Unpin for Point
impl UnwindSafe for Point
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more