Struct Plane

Source
pub struct Plane<S> {
    pub n: Vector3<S>,
    pub d: S,
}
Expand description

A 3-dimensional plane formed from the equation: A*x + B*y + C*z - D = 0.

§Fields

  • n: a unit vector representing the normal of the plane where:
    • n.x: corresponds to A in the plane equation
    • n.y: corresponds to B in the plane equation
    • n.z: corresponds to C in the plane equation
  • d: the distance value, corresponding to D in the plane equation

§Notes

The A*x + B*y + C*z - D = 0 form is preferred over the other common alternative, A*x + B*y + C*z + D = 0, because it tends to avoid superfluous negations (see Real Time Collision Detection, p. 55).

Fields§

§n: Vector3<S>

Plane normal

§d: S

Plane distance value

Implementations§

Source§

impl<S: BaseFloat> Plane<S>

Source

pub fn new(n: Vector3<S>, d: S) -> Plane<S>

Construct a plane from a normal vector and a scalar distance. The plane will be perpendicular to n, and d units offset from the origin.

Source

pub fn from_abcd(a: S, b: S, c: S, d: S) -> Plane<S>

§Arguments
  • a: the x component of the normal
  • b: the y component of the normal
  • c: the z component of the normal
  • d: the plane’s distance value
Source

pub fn from_vector4(v: Vector4<S>) -> Plane<S>

Construct a plane from the components of a four-dimensional vector

Source

pub fn from_vector4_alt(v: Vector4<S>) -> Plane<S>

Construct a plane from the components of a four-dimensional vector Assuming alternative representation: A*x + B*y + C*z + D = 0

Source

pub fn from_points(a: Point3<S>, b: Point3<S>, c: Point3<S>) -> Option<Plane<S>>

Constructs a plane that passes through the the three points a, b and c

Source

pub fn from_point_normal(p: Point3<S>, n: Vector3<S>) -> Plane<S>

Construct a plane from a point and a normal vector. The plane will contain the point p and be perpendicular to n.

Source

pub fn normalize(&self) -> Option<Plane<S>>

Normalize a plane.

Trait Implementations§

Source§

impl<S> AbsDiffEq for Plane<S>
where S::Epsilon: Copy, S: BaseFloat + AbsDiffEq,

Source§

type Epsilon = <S as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> S::Epsilon

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_eq(&self, other: &Self, epsilon: S::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

The inverse of ApproxEq::abs_diff_eq.
Source§

impl<S: Clone> Clone for Plane<S>

Source§

fn clone(&self) -> Plane<S>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<S: BaseFloat> Continuous<(Plane<S>, Plane<S>)> for Plane<S>

See Real-Time Collision Detection, p. 212 - 214

Source§

type Result = Point3<S>

Result returned by the intersection test
Source§

fn intersection(&self, planes: &(Plane<S>, Plane<S>)) -> Option<Point3<S>>

Intersection test
Source§

impl<S: BaseFloat> Continuous<Plane<S>> for Plane<S>

See Real-Time Collision Detection, p. 210

Source§

type Result = Ray<S, Point3<S>, Vector3<S>>

Result returned by the intersection test
Source§

fn intersection(&self, p2: &Plane<S>) -> Option<Ray3<S>>

Intersection test
Source§

impl<S: BaseFloat> Continuous<Ray<S, Point3<S>, Vector3<S>>> for Plane<S>

Source§

type Result = Point3<S>

Result returned by the intersection test
Source§

fn intersection(&self, r: &Ray3<S>) -> Option<Point3<S>>

Intersection test
Source§

impl<S: BaseFloat> Debug for Plane<S>

Source§

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

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

impl<S: BaseFloat> Discrete<(Plane<S>, Plane<S>)> for Plane<S>

Source§

fn intersects(&self, planes: &(Plane<S>, Plane<S>)) -> bool

Intersection test
Source§

impl<S: BaseFloat> Discrete<Plane<S>> for Plane<S>

Source§

fn intersects(&self, p2: &Plane<S>) -> bool

Intersection test
Source§

impl<S: BaseFloat> Discrete<Ray<S, Point3<S>, Vector3<S>>> for Plane<S>

Source§

fn intersects(&self, r: &Ray3<S>) -> bool

Intersection test
Source§

impl<S: PartialEq> PartialEq for Plane<S>

Source§

fn eq(&self, other: &Plane<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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<S> RelativeEq for Plane<S>
where S::Epsilon: Copy, S: BaseFloat + RelativeEq,

Source§

fn default_max_relative() -> S::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
Source§

fn relative_eq( &self, other: &Self, epsilon: S::Epsilon, max_relative: S::Epsilon, ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
Source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

The inverse of ApproxEq::relative_eq.
Source§

impl<S> UlpsEq for Plane<S>
where S::Epsilon: Copy, S: BaseFloat + UlpsEq,

Source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
Source§

fn ulps_eq(&self, other: &Self, epsilon: S::Epsilon, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
Source§

fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of ApproxEq::ulps_eq.
Source§

impl<S: Copy> Copy for Plane<S>

Source§

impl<S> StructuralPartialEq for Plane<S>

Auto Trait Implementations§

§

impl<S> Freeze for Plane<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for Plane<S>
where S: RefUnwindSafe,

§

impl<S> Send for Plane<S>
where S: Send,

§

impl<S> Sync for Plane<S>
where S: Sync,

§

impl<S> Unpin for Plane<S>
where S: Unpin,

§

impl<S> UnwindSafe for Plane<S>
where S: UnwindSafe,

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
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> 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.