pub struct Point3<T> {
pub x: T,
pub y: T,
pub z: T,
}Expand description
A point with three coordinates x, y, and z.
Fields§
§x: TThe first coordinate.
y: TThe second coordinate.
z: TThe third coordinate.
Implementations§
Source§impl<T> Point3<T>
impl<T> Point3<T>
Sourcepub fn from_array(array: [T; 3]) -> Self
pub fn from_array(array: [T; 3]) -> Self
Constructs a point from an array [x, y, z].
Sourcepub fn from_vector(vector: Vector3<T>) -> Self
pub fn from_vector(vector: Vector3<T>) -> Self
Reinterprets a displacement from the origin as a point.
Sourcepub fn to_vector(self) -> Vector3<T>
pub fn to_vector(self) -> Vector3<T>
Returns the position vector of self relative to the origin.
Source§impl<V: Scalar> Point3<V>
impl<V: Scalar> Point3<V>
Sourcepub fn distance_squared(self, rhs: Self) -> V
pub fn distance_squared(self, rhs: Self) -> V
Returns the squared Euclidean distance between self and rhs.
Cheaper than distance and sufficient whenever only
relative distances are compared.
Sourcepub fn midpoint(self, rhs: Self) -> Self
pub fn midpoint(self, rhs: Self) -> Self
Returns the midpoint of the segment between self and rhs.
Sourcepub fn centroid(points: &[Self]) -> Self
pub fn centroid(points: &[Self]) -> Self
Returns the centroid (arithmetic mean) of points, or the
ORIGIN when points is empty.
Sourcepub fn clamp(self, min: Self, max: Self) -> Self
pub fn clamp(self, min: Self, max: Self) -> Self
Restricts every coordinate to the interval [min, max], confining the
point to an axis-aligned bounding box.
§Panics
Panics if any coordinate of min exceeds the corresponding coordinate
of max.
Sourcepub fn floor(self) -> Self
pub fn floor(self) -> Self
Returns the component-wise floor (largest integer not exceeding each coordinate).
Sourcepub fn ceil(self) -> Self
pub fn ceil(self) -> Self
Returns the component-wise ceiling (smallest integer not less than each coordinate).
Sourcepub fn round(self) -> Self
pub fn round(self) -> Self
Returns the component-wise nearest integer, rounding halves away from zero.
Sourcepub fn round_ties_even(self) -> Self
pub fn round_ties_even(self) -> Self
Returns the component-wise nearest integer, rounding halves to even.
Sourcepub fn fract(self) -> Self
pub fn fract(self) -> Self
Returns the component-wise fractional part, i.e. the position of
self within the unit-grid cell it occupies.
Sourcepub fn is_infinite(self) -> bool
pub fn is_infinite(self) -> bool
Returns true if any coordinate is positive or negative infinity.
Trait Implementations§
Source§impl<T: AddAssign> AddAssign<Vector3<T>> for Point3<T>
impl<T: AddAssign> AddAssign<Vector3<T>> for Point3<T>
Source§fn add_assign(&mut self, rhs: Vector3<T>)
fn add_assign(&mut self, rhs: Vector3<T>)
+= operation. Read more