#[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
impl Plane
sourcepub const fn new(a: f32, b: f32, c: f32, d: f32) -> Self
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 planeb- The second component of the planec- The third component of the planed- The fourth component of the plane
sourcepub const fn from_normal_distance(normal: &Vec3, distance: f32) -> Self
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 planedistance- The distance of the plane
sourcepub fn from_point_and_normal(point: &Point3, normal: &Vec3) -> Self
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 planenormal- The normal of the plane
sourcepub fn from_points_clockwise(p0: &Point3, p1: &Point3, p2: &Point3) -> Self
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 pointp1- The second pointp2- The third point
sourcepub fn from_points_counter_clockwise(
p0: &Point3,
p1: &Point3,
p2: &Point3,
) -> Self
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 pointp1- The second pointp2- The third point
source§impl Plane
impl Plane
sourcepub const fn abc(&self) -> &Vec3
pub const fn abc(&self) -> &Vec3
Gets the ‘a’, ‘b’, and ‘c’ components of the plane as a 3D vector
sourcepub const fn bcd(&self) -> &Vec3
pub const fn bcd(&self) -> &Vec3
Gets the ‘b’, ‘c’, and ‘d’ components of the plane as a 3D vector
sourcepub const fn abcd(&self) -> &Vec4
pub const fn abcd(&self) -> &Vec4
Gets the ‘a’, ‘b’, ‘c’, and ‘d’ components of the plane as a 4D vector
sourcepub fn ab_mut(&mut self) -> &mut Vec2
pub fn ab_mut(&mut self) -> &mut Vec2
Gets the ‘a’ and ‘b’ components of the plane as a 2D vector
sourcepub fn bc_mut(&mut self) -> &mut Vec2
pub fn bc_mut(&mut self) -> &mut Vec2
Gets the ‘b’ and ‘c’ components of the plane as a 2D vector
sourcepub fn cd_mut(&mut self) -> &mut Vec2
pub fn cd_mut(&mut self) -> &mut Vec2
Gets the ‘c’ and ‘d’ components of the plane as a 2D vector
sourcepub fn abc_mut(&mut self) -> &mut Vec3
pub fn abc_mut(&mut self) -> &mut Vec3
Gets the ‘a’, ‘b’, and ‘c’ components of the plane as a 3D vector
sourcepub fn bcd_mut(&mut self) -> &mut Vec3
pub fn bcd_mut(&mut self) -> &mut Vec3
Gets the ‘b’, ‘c’, and ‘d’ components of the plane as a 3D vector
sourcepub fn abcd_mut(&mut self) -> &mut Vec4
pub fn abcd_mut(&mut self) -> &mut Vec4
Gets the ‘a’, ‘b’, ‘c’, and ‘d’ components of the plane as a 4D vector
sourcepub fn set_ab(&mut self, ab: &Vec2)
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
sourcepub fn set_bc(&mut self, bc: &Vec2)
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
sourcepub fn set_cd(&mut self, cd: &Vec2)
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
sourcepub fn set_abc(&mut self, abc: &Vec3)
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§impl Plane
impl Plane
sourcepub fn distance_to_point(&self, point: &Point3) -> f32
pub fn distance_to_point(&self, point: &Point3) -> f32
sourcepub fn contains_point(&self, point: &Point3) -> bool
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
sourcepub fn is_point_over_plane(&self, point: &Point3) -> bool
pub fn is_point_over_plane(&self, point: &Point3) -> bool
sourcepub fn is_point_under_plane(&self, point: &Point3) -> bool
pub fn is_point_under_plane(&self, point: &Point3) -> bool
sourcepub fn nearest_point(&self, point: &Point3) -> Point3
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
Methods from Deref<Target = Vec4>§
sourcepub fn as_mut_slice(&mut self) -> &mut [f32]
pub fn as_mut_slice(&mut self) -> &mut [f32]
sourcepub fn as_mut_ptr(&mut self) -> *mut f32
pub fn as_mut_ptr(&mut self) -> *mut f32
Returns this vector as a mutable ptr of f32.
sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut f32>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut f32>
Returns a mutable iterator over the vector.
sourcepub fn x_mut(&mut self) -> &mut f32
pub fn x_mut(&mut self) -> &mut f32
Returns a mutable reference to the X-coordinate of this 3-component vector.
sourcepub fn y_mut(&mut self) -> &mut f32
pub fn y_mut(&mut self) -> &mut f32
Returns a mutable reference to the Y-coordinate of this 3-component vector.
sourcepub fn z_mut(&mut self) -> &mut f32
pub fn z_mut(&mut self) -> &mut f32
Returns a mutable reference to the Z-coordinate of this 3-component vector.
sourcepub fn w_mut(&mut self) -> &mut f32
pub fn w_mut(&mut self) -> &mut f32
Returns a mutable reference to the W-coordinate of this 3-component vector.
sourcepub fn xy_mut(&mut self) -> &mut Vec2
pub fn xy_mut(&mut self) -> &mut Vec2
Returns a mutable reference to the xy coordinates of this vector.
sourcepub fn yz_mut(&mut self) -> &mut Vec2
pub fn yz_mut(&mut self) -> &mut Vec2
Returns a mutable reference to the yz coordinates of this vector.
sourcepub fn zw_mut(&mut self) -> &mut Vec2
pub fn zw_mut(&mut self) -> &mut Vec2
Returns a mutable reference to the zw coordinates of this vector.
sourcepub fn xyz_mut(&mut self) -> &mut Vec3
pub fn xyz_mut(&mut self) -> &mut Vec3
Returns a mutable reference to the yz coordinates of this vector.
sourcepub fn yzw_mut(&mut self) -> &mut Vec3
pub fn yzw_mut(&mut self) -> &mut Vec3
Returns a mutable reference to the zw coordinates of this vector.
sourcepub fn square_magnitude(&self) -> f32
pub fn square_magnitude(&self) -> f32
Computes the square magnitude of this two-component vector.
sourcepub fn magnitude(&self) -> f32
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.
sourcepub fn is_normalized(&self) -> bool
pub fn is_normalized(&self) -> bool
Queries whether this vector is normalized (e.g. has a magnitude of 1).
sourcepub fn normalized(&self) -> Vector4
pub fn normalized(&self) -> Vector4
Returns normalized vector.
sourcepub fn is_finite(&self) -> bool
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());sourcepub fn is_infinite(&self) -> bool
pub fn is_infinite(&self) -> bool
Trait Implementations§
source§impl Intersects for Plane
impl Intersects for Plane
source§fn intersects(&self, other: &Self) -> bool
fn intersects(&self, other: &Self) -> bool
source§impl PartialOrd for Plane
impl PartialOrd for Plane
impl Copy for Plane
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)