#[repr(transparent)]pub struct Point<Repr, Space = ()>(pub Repr, _);Tuple Fields§
§0: ReprImplementations§
Source§impl<Sc: Copy, Sp, const N: usize> Point<[Sc; N], Sp>
impl<Sc: Copy, Sp, const N: usize> Point<[Sc; N], Sp>
Sourcepub fn map<T>(self, f: impl FnMut(Sc) -> T) -> Point<[T; N], Sp>
pub fn map<T>(self, f: impl FnMut(Sc) -> T) -> Point<[T; N], Sp>
Returns a vector of the same dimension as self by applying f
component-wise.
§Examples
use retrofire_core::math::{pt3};
let p = pt3::<i32, ()>(1, 2, 3);
assert_eq!(p.map(|x| x as f32 + 0.5), pt3(1.5, 2.5, 3.5));Sourcepub fn zip_map<T: Copy, U>(
self,
other: Point<[T; N], Sp>,
f: impl FnMut(Sc, T) -> U,
) -> Point<[U; N], Sp>
pub fn zip_map<T: Copy, U>( self, other: Point<[T; N], Sp>, f: impl FnMut(Sc, T) -> U, ) -> Point<[U; N], Sp>
Returns a vector of the same dimension as self by applying f
component-wise to self and other.
§Examples
use retrofire_core::math::pt3;
let a = pt3::<f32, ()>(1.0, 2.0, 3.0);
let b = pt3(4, 3, 2);
assert_eq!(a.zip_map(b, |x, exp| x.powi(exp)), pt3(1.0, 8.0, 9.0));Source§impl<const N: usize, B> Point<[f32; N], Real<N, B>>
impl<const N: usize, B> Point<[f32; N], Real<N, B>>
Sourcepub fn distance(&self, other: &Self) -> f32
pub fn distance(&self, other: &Self) -> f32
Returns the Euclidean distance between self and another point.
§Example
use retrofire_core::math::{Point2, pt2};
let x3: Point2 = pt2(3.0, 0.0);
let y4 = pt2(0.0, 4.0);
assert_eq!(x3.distance(&y4), 5.0);Sourcepub fn distance_sqr(&self, other: &Self) -> f32
pub fn distance_sqr(&self, other: &Self) -> f32
Sourcepub fn clamp(&self, min: &Self, max: &Self) -> Self
pub fn clamp(&self, min: &Self, max: &Self) -> Self
Returns self clamped component-wise to the given range.
The result is a vector v such that for each valid index i,
v[i] is equal to self[i].clamp(min[i], max[i]).
See also f32::clamp.
§Panics
If min[i] > max[i] for any valid index i,
or if either min or max contains a NaN.
§Examples
use retrofire_core::math::{pt3, Point3};
let pt: Point3 = pt3(0.5, 1.5, -2.0);
// Clamp to the unit cube
let clamped = pt.clamp(&pt3(0.0, 0.0, 0.0), &pt3(1.0, 1.0, 1.0));
assert_eq!(clamped, pt3(0.5, 1.0, 0.0));Trait Implementations§
Source§impl<ScSelf, ScDiff, Sp, const N: usize> Affine for Point<[ScSelf; N], Sp>
impl<ScSelf, ScDiff, Sp, const N: usize> Affine for Point<[ScSelf; N], Sp>
Source§impl<Src, Dest> Apply<Point<[f32; 2], Real<2, Src>>> for Mat2x2<RealToReal<2, Src, Dest>>
impl<Src, Dest> Apply<Point<[f32; 2], Real<2, Src>>> for Mat2x2<RealToReal<2, Src, Dest>>
Source§impl<Src, Dest> Apply<Point<[f32; 2], Real<2, Src>>> for Mat3x3<RealToReal<2, Src, Dest>>
impl<Src, Dest> Apply<Point<[f32; 2], Real<2, Src>>> for Mat3x3<RealToReal<2, Src, Dest>>
Source§fn apply(&self, p: &Point2<Src>) -> Point2<Dest>
fn apply(&self, p: &Point2<Src>) -> Point2<Dest>
Maps a real 2-point from basis Src to basis Dst.
Computes the affine matrix–point multiplication 𝝡p where p is interpreted as a column vector with an implicit p2 component with value 1:
⎛ M00 · · ⎞ ⎛ p0 ⎞ ⎛ p0' ⎞
Mp = ⎜ · · · ⎟ ⎜ p1 ⎟ = ⎜ p1' ⎟
⎝ · · M22 ⎠ ⎝ 1 ⎠ ⎝ 1 ⎠Source§impl<Src, Dest> Apply<Point<[f32; 3], Real<3, Src>>> for Mat3x3<RealToReal<3, Src, Dest>>
impl<Src, Dest> Apply<Point<[f32; 3], Real<3, Src>>> for Mat3x3<RealToReal<3, Src, Dest>>
Source§impl<Src> Apply<Point<[f32; 3], Real<3, Src>>> for Mat4x4<RealToProj<Src>>
impl<Src> Apply<Point<[f32; 3], Real<3, Src>>> for Mat4x4<RealToProj<Src>>
Source§fn apply(&self, p: &Point3<Src>) -> ProjVec3
fn apply(&self, p: &Point3<Src>) -> ProjVec3
Maps the real 3-point p from basis B to the projective 3-space.
Computes the matrix–point multiplication Mp where p is interpreted as a column vector with an implicit p3 component with value 1:
⎛ M00 · · ⎞ ⎛ p0 ⎞ ⎛ p0' ⎞
Mp = ⎜ · ⎟ ⎜ p1 ⎟ = ⎜ p1' ⎟
⎜ · ⎟ ⎜ p2 ⎟ ⎜ p2' ⎟
⎝ · · M33 ⎠ ⎝ 1 ⎠ ⎝ p3' ⎠Source§impl<Src, Dst> Apply<Point<[f32; 3], Real<3, Src>>> for Mat4x4<RealToReal<3, Src, Dst>>
impl<Src, Dst> Apply<Point<[f32; 3], Real<3, Src>>> for Mat4x4<RealToReal<3, Src, Dst>>
Source§fn apply(&self, p: &Point3<Src>) -> Point3<Dst>
fn apply(&self, p: &Point3<Src>) -> Point3<Dst>
Maps a real 3-point from basis Src to basis Dst.
Computes the affine matrix–point multiplication 𝝡p where p is interpreted as a column vector with an implicit p3 component with value 1:
⎛ M00 · · · ⎞ ⎛ p0 ⎞ ⎛ p0' ⎞
Mp = ⎜ · · · · ⎟ ⎜ p1 ⎟ = ⎜ p1' ⎟
⎜ · · · · ⎟ ⎜ p2 ⎟ ⎜ p2' ⎟
⎝ · · · M33 ⎠ ⎝ 1 ⎠ ⎝ 1 ⎠Source§impl<Sc: ApproxEq, Sp, const N: usize> ApproxEq<Point<[Sc; N], Sp>, Sc> for Point<[Sc; N], Sp>
impl<Sc: ApproxEq, Sp, const N: usize> ApproxEq<Point<[Sc; N], Sp>, Sc> for Point<[Sc; N], Sp>
Source§fn approx_eq_eps(&self, other: &Self, eps: &Sc) -> bool
fn approx_eq_eps(&self, other: &Self, eps: &Sc) -> bool
self and other are approximately equal,
using the relative epsilon rel_eps.Source§fn relative_epsilon() -> Sc
fn relative_epsilon() -> Sc
E.Source§impl<'a, B: Default> Extend<&'a Point<[f32; 3], Real<3, B>>> for BBox<B>
impl<'a, B: Default> Extend<&'a Point<[f32; 3], Real<3, B>>> for BBox<B>
Source§fn extend<I: IntoIterator<Item = &'a Point3<B>>>(&mut self, it: I)
fn extend<I: IntoIterator<Item = &'a Point3<B>>>(&mut self, it: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)