Expand description
An n-dimensional point
The dimensionality of the point is defined by the const generic D
parameter.
Fields§
§coords: Vector<D>The coordinates of the point
Implementations§
source§impl<const D: usize> Point<D>
impl<const D: usize> Point<D>
sourcepub fn from_array(array: [f64; D]) -> Self
pub fn from_array(array: [f64; D]) -> Self
Construct a Point from an array
sourcepub fn to_na(self) -> Point<f64, D>
pub fn to_na(self) -> Point<f64, D>
Convert the point into an nalgebra point
Examples found in repository?
src/point.rs (line 152)
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
fn neg(self) -> Self::Output {
self.to_na().neg().into()
}
}
impl<V, const D: usize> ops::Add<V> for Point<D>
where
V: Into<Vector<D>>,
{
type Output = Self;
fn add(self, rhs: V) -> Self::Output {
self.to_na().add(rhs.into().to_na()).into()
}
}
impl<V, const D: usize> ops::Sub<V> for Point<D>
where
V: Into<Vector<D>>,
{
type Output = Self;
fn sub(self, rhs: V) -> Self::Output {
self.to_na().sub(rhs.into().to_na()).into()
}
}
impl<const D: usize> ops::Sub<Self> for Point<D> {
type Output = Vector<D>;
fn sub(self, rhs: Self) -> Self::Output {
self.to_na().sub(rhs.to_na()).into()
}
}
impl<const D: usize> ops::Sub<Point<D>> for &Point<D> {
type Output = Vector<D>;
fn sub(self, rhs: Point<D>) -> Self::Output {
self.to_na().sub(rhs.to_na()).into()
}
}
impl<const D: usize> ops::Mul<f64> for Point<D> {
type Output = Self;
fn mul(self, rhs: f64) -> Self::Output {
self.to_na().mul(rhs).into()
}More examples
src/triangle.rs (line 81)
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
pub fn to_parry(self) -> parry3d_f64::shape::Triangle {
self.points().map(|vertex| vertex.to_na()).into()
}
/// Cast a ray against the Triangle
pub fn cast_local_ray(
&self,
origin: Point<3>,
dir: Vector<3>,
max_toi: f64,
solid: bool,
) -> Option<Scalar> {
let ray = Ray {
origin: origin.to_na(),
dir: dir.to_na(),
};
self.to_parry()
.cast_local_ray(&ray, max_toi, solid)
.map(Into::into)
}src/aabb.rs (line 58)
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
pub fn from_points(
points: impl IntoIterator<Item = impl Into<Point<2>>>,
) -> Self {
let points: Vec<_> = points
.into_iter()
.map(|point| point.into().to_na())
.collect();
parry2d_f64::bounding_volume::Aabb::from_points(&points).into()
}
/// Construct a 2-dimensional AABB from a Parry AABB
pub fn from_parry(aabb: parry2d_f64::bounding_volume::Aabb) -> Self {
Self {
min: aabb.mins.into(),
max: aabb.maxs.into(),
}
}
}
impl Aabb<3> {
/// Construct a 3-dimensional AABB from a list of points
///
/// The resulting AABB will contain all the points.
pub fn from_points(
points: impl IntoIterator<Item = impl Into<Point<3>>>,
) -> Self {
let points: Vec<_> = points
.into_iter()
.map(|point| point.into().to_na())
.collect();
parry3d_f64::bounding_volume::Aabb::from_points(&points).into()
}
/// Construct a 3-dimensional AABB from a Parry AABB
pub fn from_parry(aabb: parry3d_f64::bounding_volume::Aabb) -> Self {
Self {
min: aabb.mins.into(),
max: aabb.maxs.into(),
}
}
/// Convert the AABB to a Parry AABB
pub fn to_parry(self) -> parry3d_f64::bounding_volume::Aabb {
parry3d_f64::bounding_volume::Aabb {
mins: self.min.to_na(),
maxs: self.max.to_na(),
}
}
/// Access the vertices of the AABB
pub fn vertices(&self) -> [Point<3>; 8] {
self.to_parry().vertices().map(Into::into)
}
/// Compute the center point of the AABB
pub fn center(&self) -> Point<3> {
self.to_parry().center().into()
}
/// Compute the size of the AABB
pub fn size(&self) -> Vector<3> {
self.to_parry().extents().into()
}
/// Compute an AABB that includes an additional point
pub fn include_point(self, point: &Point<3>) -> Self {
let mut aabb = self.to_parry();
aabb.take_point(point.to_na());
Self::from_parry(aabb)
}sourcepub fn to_xyz(self) -> Point<3>
pub fn to_xyz(self) -> Point<3>
Convert to a 3-dimensional point
See Vector::to_xyz for details. This method follows the same rules.
sourcepub fn distance_to(&self, other: &Self) -> Scalar
pub fn distance_to(&self, other: &Self) -> Scalar
Gives the distance between two points.
Trait Implementations§
source§impl<const D: usize> AbsDiffEq<Point<D>> for Point<D>
impl<const D: usize> AbsDiffEq<Point<D>> for Point<D>
§type Epsilon = <Vector<D> as AbsDiffEq<Vector<D>>>::Epsilon
type Epsilon = <Vector<D> as AbsDiffEq<Vector<D>>>::Epsilon
Used for specifying relative comparisons.
source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
The default tolerance to use when testing values that are close together. Read more
source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
A test for equality that uses the absolute difference to compute the approximate
equality of two numbers.
source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of
AbsDiffEq::abs_diff_eq.source§impl<const D: usize> Ord for Point<D>
impl<const D: usize> Ord for Point<D>
source§impl<const D: usize> PartialEq<Point<D>> for Point<D>
impl<const D: usize> PartialEq<Point<D>> for Point<D>
source§impl<const D: usize> PartialOrd<Point<D>> for Point<D>
impl<const D: usize> PartialOrd<Point<D>> for Point<D>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl<const D: usize> Copy for Point<D>
impl<const D: usize> Eq for Point<D>
impl<const D: usize> StructuralEq for Point<D>
impl<const D: usize> StructuralPartialEq for Point<D>
Auto Trait Implementations§
impl<const D: usize> RefUnwindSafe for Point<D>
impl<const D: usize> Send for Point<D>
impl<const D: usize> Sync for Point<D>
impl<const D: usize> Unpin for Point<D>
impl<const D: usize> UnwindSafe for Point<D>
Blanket Implementations§
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.