alloy::geometry

Struct Plane

source
#[repr(C)]
pub struct Plane { /* private fields */ }
Expand description

A value type that represents a plane in 3D space with the equation: a*x + b*y + c*z + d = 0.

Points can implicitly deref into Vec4 to allow for easily using points in places where vectors are expected.

Implementations§

source§

impl Plane

source

pub const fn new(a: f32, b: f32, c: f32, d: f32) -> Self

Creates a new plane with the given coefficients.

§Parameters
  • a - The first component of the plane
  • b - The second component of the plane
  • c - The third component of the plane
  • d - The fourth component of the plane
source

pub const fn from_normal_distance(normal: &Vec3, distance: f32) -> Self

Create a new plane from a normal and distance

§Parameters
  • normal - The normal of the plane
  • distance - The distance of the plane
source

pub fn from_point_and_normal(point: &Point3, normal: &Vec3) -> Self

Create a new plane from a point and normal

§Parameters
  • point - The point on the plane
  • normal - The normal of the plane
source

pub fn from_points_clockwise(p0: &Point3, p1: &Point3, p2: &Point3) -> Self

Create a new plane from three points in counter-clockwise order.

§Parameters
  • p0 - The first point
  • p1 - The second point
  • p2 - The third point
source

pub fn from_points_counter_clockwise( p0: &Point3, p1: &Point3, p2: &Point3, ) -> Self

Create a new plane from three points in counter-clockwise order. This is the same as from_points_clockwise but with the points in a different order.

§Parameters
  • p0 - The first point
  • p1 - The second point
  • p2 - The third point
source§

impl Plane

source

pub const fn a(&self) -> f32

Gets the ‘a’ component of the plane

source

pub const fn b(&self) -> f32

Gets the ‘b’ component of the plane

source

pub const fn c(&self) -> f32

Gets the ‘c’ component of the plane

source

pub const fn d(&self) -> f32

Gets the ‘d’ component of the plane

source

pub const fn ab(&self) -> &Vec2

Gets the ‘a’ and ‘b’ components of the plane as a 2D vector

source

pub const fn bc(&self) -> &Vec2

Gets the ‘b’ and ‘c’ components of the plane as a 2D vector

source

pub const fn cd(&self) -> &Vec2

Gets the ‘c’ and ‘d’ components of the plane as a 2D vector

source

pub const fn abc(&self) -> &Vec3

Gets the ‘a’, ‘b’, and ‘c’ components of the plane as a 3D vector

source

pub const fn bcd(&self) -> &Vec3

Gets the ‘b’, ‘c’, and ‘d’ components of the plane as a 3D vector

source

pub const fn abcd(&self) -> &Vec4

Gets the ‘a’, ‘b’, ‘c’, and ‘d’ components of the plane as a 4D vector

source

pub const fn normal(&self) -> &Vec3

Gets the normal of this plane

source

pub fn a_mut(&mut self) -> &mut f32

Gets the ‘a’ component of the plane

source

pub fn b_mut(&mut self) -> &mut f32

Gets the ‘b’ component of the plane

source

pub fn c_mut(&mut self) -> &mut f32

Gets the ‘c’ component of the plane

source

pub fn d_mut(&mut self) -> &mut f32

Gets the ‘d’ component of the plane

source

pub fn ab_mut(&mut self) -> &mut Vec2

Gets the ‘a’ and ‘b’ components of the plane as a 2D vector

source

pub fn bc_mut(&mut self) -> &mut Vec2

Gets the ‘b’ and ‘c’ components of the plane as a 2D vector

source

pub fn cd_mut(&mut self) -> &mut Vec2

Gets the ‘c’ and ‘d’ components of the plane as a 2D vector

source

pub fn abc_mut(&mut self) -> &mut Vec3

Gets the ‘a’, ‘b’, and ‘c’ components of the plane as a 3D vector

source

pub fn bcd_mut(&mut self) -> &mut Vec3

Gets the ‘b’, ‘c’, and ‘d’ components of the plane as a 3D vector

source

pub fn abcd_mut(&mut self) -> &mut Vec4

Gets the ‘a’, ‘b’, ‘c’, and ‘d’ components of the plane as a 4D vector

source

pub fn set_a(&mut self, a: f32)

Sets the ‘a’ component of the plane

§Parameters
  • a - The new value of the ‘a’ component
source

pub fn set_b(&mut self, b: f32)

Sets the ‘b’ component of the plane

§Parameters
  • b - The new value of the ‘b’ component
source

pub fn set_c(&mut self, c: f32)

Sets the ‘c’ component of the plane

§Parameters
  • c - The new value of the ‘c’ component
source

pub fn set_d(&mut self, d: f32)

Sets the ‘d’ component of the plane

§Parameters
  • d - The new value of the ‘d’ component
source

pub fn set_ab(&mut self, ab: &Vec2)

Gets the ‘a’ and ‘b’ components of the plane

§Parameters
  • ab - The new value of the ‘a’ and ‘b’ components
source

pub fn set_bc(&mut self, bc: &Vec2)

Gets the ‘b’ and ‘c’ components of the plane

§Parameters
  • bc - The new value of the ‘b’ and ‘c’ components
source

pub fn set_cd(&mut self, cd: &Vec2)

Gets the ‘c’ and ‘d’ components of the plane

§Parameters
  • cd - The new value of the ‘c’ and ‘d’ components
source

pub fn set_abc(&mut self, abc: &Vec3)

Gets the ‘a’, ‘b’, and ‘c’ components of the plane

§Parameters
  • abc - The new value of the ‘a’, ‘b’, and ‘c’ components
source

pub fn set_bcd(&mut self, bcd: &Vec3)

Gets the ‘b’, ‘c’, and ‘d’ components of the plane

§Parameters
  • bcd - The new value of the ‘b’, ‘c’, and ‘d’ components
source

pub fn set(&mut self, abcd: &Vec4)

Gets the ‘a’, ‘b’, ‘c’, and ‘d’ components of the plane

§Parameters
  • abcd - The new value of the ‘a’, ‘b’, ‘c’, and ‘d’ components
source§

impl Plane

source

pub const fn as_vec4(&self) -> &Vec4

Gets the normal of this plane

source

pub fn as_mut_vec4(&mut self) -> &mut Vec4

Gets the normal of this plane

source§

impl Plane

source

pub fn distance_to_point(&self, point: &Point3) -> f32

Gets the distance to the point from this plane

§Parameters
  • point - The point to get the distance to
source

pub fn contains_point(&self, point: &Point3) -> bool

Checks if the plane contains the point within the default epsilon.

§Parameters
  • point - The point to check
source

pub fn is_point_over_plane(&self, point: &Point3) -> bool

Checks if the point exists over the plane

§Parameters
  • point - The point to check
source

pub fn is_point_under_plane(&self, point: &Point3) -> bool

Checks if the point exists under the plane

§Parameters
  • point - The point to check
source

pub fn nearest_point(&self, point: &Point3) -> Point3

Gets the nearest point on the plane to the given point

§Parameters
  • point - The point to get the nearest point to
source§

impl Plane

source

pub fn inverted(&self) -> Self

Computes and returns the plane that is this plane’s inverse.

Methods from Deref<Target = Vec4>§

source

pub fn as_slice(&self) -> &[f32]

Returns this Vec4 as a slice of f32.

source

pub fn as_mut_slice(&mut self) -> &mut [f32]

Returns this Vec4 as a mutable slice of f32.

source

pub fn as_ptr(&self) -> *const f32

Returns this vector as a ptr of f32.

source

pub fn as_mut_ptr(&mut self) -> *mut f32

Returns this vector as a mutable ptr of f32.

source

pub fn iter(&self) -> impl Iterator<Item = &f32>

Returns an iterator over the vector.

source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut f32>

Returns a mutable iterator over the vector.

source

pub fn x(&self) -> f32

Returns the X-coordinate of this 4-component vector.

source

pub fn y(&self) -> f32

Returns the Y-coordinate of this 4-component vector.

source

pub fn z(&self) -> f32

Returns the Z-coordinate of this 4-component vector.

source

pub fn w(&self) -> f32

Returns the W-coordinate of this 4-component vector.

source

pub fn xy(&self) -> &Vec2

Returns the xy coordinates of this vector as a Vec2.

source

pub fn yz(&self) -> &Vec2

Returns the yz coordinates of this vector as a Vec2.

source

pub fn zw(&self) -> &Vec2

Returns the zw coordinates of this vector as a Vec2.

source

pub fn xyz(&self) -> &Vec3

Returns the xyz coordinates of this vector as a Vec2.

source

pub fn yzw(&self) -> &Vec3

Returns the yz coordinates of this vector as a Vec2.

source

pub fn x_mut(&mut self) -> &mut f32

Returns a mutable reference to the X-coordinate of this 3-component vector.

source

pub fn y_mut(&mut self) -> &mut f32

Returns a mutable reference to the Y-coordinate of this 3-component vector.

source

pub fn z_mut(&mut self) -> &mut f32

Returns a mutable reference to the Z-coordinate of this 3-component vector.

source

pub fn w_mut(&mut self) -> &mut f32

Returns a mutable reference to the W-coordinate of this 3-component vector.

source

pub fn xy_mut(&mut self) -> &mut Vec2

Returns a mutable reference to the xy coordinates of this vector.

source

pub fn yz_mut(&mut self) -> &mut Vec2

Returns a mutable reference to the yz coordinates of this vector.

source

pub fn zw_mut(&mut self) -> &mut Vec2

Returns a mutable reference to the zw coordinates of this vector.

source

pub fn xyz_mut(&mut self) -> &mut Vec3

Returns a mutable reference to the yz coordinates of this vector.

source

pub fn yzw_mut(&mut self) -> &mut Vec3

Returns a mutable reference to the zw coordinates of this vector.

source

pub fn square_magnitude(&self) -> f32

Computes the square magnitude of this two-component vector.

source

pub fn magnitude(&self) -> f32

Computes the magnitude of this vector.

Where possible, consider using Vec4::square_magnitude as this will avoid the need to compute the square-root.

source

pub fn is_normalized(&self) -> bool

Queries whether this vector is normalized (e.g. has a magnitude of 1).

source

pub fn normalize(&mut self)

Normalizes this vector.

source

pub fn normalized(&self) -> Vector4

Returns normalized vector.

source

pub fn is_finite(&self) -> bool

Returns whether all components of this Vec are finite.

§Example

Basic use:


let finite = Vector4::UNIT_X;
let not_finite = Vector4::new(f32::INFINITY, 3.0, 0.0, -1.0);

assert!(finite.is_finite());
assert!(!not_finite.is_finite());
source

pub fn is_infinite(&self) -> bool

Returns whether any component of this vec are infinite.

This is the inverse operation of is_finite.

§Example

Basic use:


let finite = Vector4::UNIT_X;
let not_finite = Vector4::new(f32::INFINITY, 3.0, 0.0, -1.0);

assert!(!finite.is_infinite());
assert!(not_finite.is_infinite());
source

pub fn is_nan(&self) -> bool

Returns whether any component of this vec are nan.

source

pub fn abs(&self) -> Vector4

Computes the absolute value of self

source

pub fn min(&self, rhs: &Vec4) -> Vector4

Computes the minimum of each vector.

§Parameters
  • lhs - the left vector
  • rhs - the right vector
source

pub fn max(&self, rhs: &Vec4) -> Vector4

Computes the maximum of each vector.

§Parameters
  • lhs - the left vector
  • rhs - the right vector
source

pub fn set_x(&mut self, x: f32)

Sets the x-component

§Parameters
  • x - the X-component
source

pub fn set_y(&mut self, y: f32)

Sets the y-component

§Parameters
  • y - the Y-component
source

pub fn set_z(&mut self, z: f32)

Sets the z-component

§Parameters
  • z - theZ-component
source

pub fn set_w(&mut self, w: f32)

Sets the w-component

§Parameters
  • w - the W-component
source

pub fn set_xy(&mut self, xy: &Vec2)

Sets the X and Y components of this vector

§Parameters
  • xy - the X and Y components of the Vec4
source

pub fn set_yz(&mut self, yz: &Vec2)

Sets the Y and Z components of this vector

§Parameters
  • yz - the Y and Z components of the Vec4
source

pub fn set_zw(&mut self, zw: &Vec2)

Sets the Z and W components of this vector

§Parameters
  • zw - the Z and W components of the Vec4
source

pub fn set_xyz(&mut self, xyz: &Vec3)

Sets the X, Y, and Z components of this vector

§Parameters
  • xyz - the X, Y, and Z components of the Vec4`
source

pub fn set_yzw(&mut self, yzw: &Vec3)

Sets the Y, Z and W components of this vector

§Parameters
  • yzw - the Y, Z, and W components of the Vec4
source

pub fn set(&mut self, other: &Vec4)

Sets all the components of this vector the values from other.

§Parameters
  • other - the other Vec3 to set.

Trait Implementations§

source§

impl AsMut<Vec4> for Plane

source§

fn as_mut(&mut self) -> &mut Vec4

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<Vec4> for Plane

source§

fn as_ref(&self) -> &Vec4

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Plane

source§

fn clone(&self) -> Plane

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 Debug for Plane

source§

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

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

impl Default for Plane

source§

fn default() -> Plane

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

impl Deref for Plane

source§

type Target = Vec4

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl DerefMut for Plane

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl Encloses<Point3> for Plane

source§

fn encloses(&self, point: &Point3) -> bool

Determines if this object encloses another object. Read more
source§

impl Intersects for Plane

source§

fn intersects(&self, other: &Self) -> bool

Determines if this object intersects with another object. Read more
source§

impl PartialEq for Plane

source§

fn eq(&self, other: &Plane) -> 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 PartialOrd for Plane

source§

fn partial_cmp(&self, other: &Plane) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for Plane

source§

impl StructuralPartialEq for Plane

Auto Trait Implementations§

§

impl Freeze for Plane

§

impl RefUnwindSafe for Plane

§

impl Send for Plane

§

impl Sync for Plane

§

impl Unpin for Plane

§

impl UnwindSafe for Plane

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.