Skip to main content

Point

Struct Point 

Source
pub struct Point {
    pub x: f64,
    pub y: f64,
    pub z: f64,
}
Expand description

A position in space.

Fields§

§x: f64

X coordinate.

§y: f64

Y coordinate.

§z: f64

Z coordinate.

Implementations§

Source§

impl Point

Source

pub const ORIGIN: Self

The origin.

Source

pub const fn new(x: f64, y: f64, z: f64) -> Self

A point from coordinates.

Source

pub const fn to_array(self) -> [f64; 3]

Coordinates as an array.

Source

pub const fn from_array([x, y, z]: [f64; 3]) -> Self

A point from an array.

Source

pub const fn to_vector(self) -> Vector

The position vector from the origin.

Source

pub const fn from_vector(v: Vector) -> Self

The point at the tip of v placed at the origin.

Source

pub fn coord(self, index: usize) -> OgeomResult<f64>

Coordinate by index, 0..3.

§Errors

OgeomError::Range if index >= 3.

Source

pub fn square_distance(self, other: Self) -> f64

Squared distance to other. Prefer this when comparing distances.

Source

pub fn distance(self, other: Self) -> f64

Distance to other.

Source

pub fn is_equal(self, other: Self, tol: Tolerances) -> bool

Whether two points coincide within tol.confusion().

Source

pub fn is_within(self, other: Self, distance: f64) -> bool

Whether two points coincide within an explicit distance.

Source

pub fn is_finite(self) -> bool

Whether every coordinate is finite.

Source

pub fn midpoint(self, other: Self) -> Self

The midpoint of self and other.

Source

pub fn lerp(self, other: Self, t: f64) -> Self

Linear interpolation, t = 0 giving self.

Source

pub fn centroid(points: &[Self]) -> OgeomResult<Self>

The centroid of a set of points.

§Errors

OgeomError::Construction if the set is empty.

Source

pub fn min(self, other: Self) -> Self

Component-wise minimum.

Source

pub fn max(self, other: Self) -> Self

Component-wise maximum.

Source

pub const fn xy(self) -> Point2

This point with the Z coordinate dropped.

Trait Implementations§

Source§

impl Add<Vector> for Point

Source§

type Output = Point

The resulting type after applying the + operator.
Source§

fn add(self, v: Vector) -> Self

Performs the + operation. Read more
Source§

impl AddAssign<Vector> for Point

Source§

fn add_assign(&mut self, v: Vector)

Performs the += operation. Read more
Source§

impl Blend for Point

Source§

fn zero() -> Self

The additive identity.
Source§

fn scale(self, k: f64) -> Self

Scale by a factor.
Source§

fn add(self, other: Self) -> Self

Add another value.
Source§

fn lerp(self, other: Self, t: f64) -> Self

self * (1 - t) + other * t.
Source§

fn sub(self, other: Self) -> Self

Subtract, via scaling by -1.
Source§

impl Clone for Point

Source§

fn clone(&self) -> Point

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Point

Source§

impl Debug for Point

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Point

Source§

fn default() -> Point

Returns the “default value” for a type. Read more
Source§

impl FromIterator<Point> for Aabb

Source§

fn from_iter<I: IntoIterator<Item = Point>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl PartialEq for Point

Source§

fn eq(&self, other: &Point) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Point

Source§

impl Sub for Point

Source§

fn sub(self, other: Self) -> Vector

The displacement from other to self.

Source§

type Output = Vector

The resulting type after applying the - operator.
Source§

impl Sub<Vector> for Point

Source§

type Output = Point

The resulting type after applying the - operator.
Source§

fn sub(self, v: Vector) -> Self

Performs the - operation. Read more
Source§

impl SubAssign<Vector> for Point

Source§

fn sub_assign(&mut self, v: Vector)

Performs the -= operation. Read more

Auto Trait Implementations§

§

impl Freeze for Point

§

impl RefUnwindSafe for Point

§

impl Send for Point

§

impl Sync for Point

§

impl Unpin for Point

§

impl UnsafeUnpin for Point

§

impl UnwindSafe for Point

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T, Right> ClosedAdd<Right> for T
where T: Add<Right, Output = T> + AddAssign<Right>,

§

impl<T, Right> ClosedAddAssign<Right> for T
where T: ClosedAdd<Right> + AddAssign<Right>,

§

impl<T, Right> ClosedSub<Right> for T
where T: Sub<Right, Output = T> + SubAssign<Right>,

§

impl<T, Right> ClosedSubAssign<Right> for T
where T: ClosedSub<Right> + SubAssign<Right>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

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

Checks if self is actually part of its subset T (and can be converted to it).
§

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

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.