pub struct Rectangle { /* private fields */ }Expand description
A rectangle (quad) in 3D space, defined by a corner and two edge vectors.
The four vertices are:
originorigin + uorigin + u + vorigin + v
Implementations§
Source§impl Rectangle
impl Rectangle
Sourcepub fn new(origin: Point3<f32>, u: Vector3<f32>, v: Vector3<f32>) -> Self
pub fn new(origin: Point3<f32>, u: Vector3<f32>, v: Vector3<f32>) -> Self
Creates a new rectangle from an origin corner and two edge vectors.
The vertices will be: origin, origin+u, origin+u+v, origin+v (counter-clockwise).
Sourcepub fn from_corners(
a: Point3<f32>,
b: Point3<f32>,
c: Point3<f32>,
d: Point3<f32>,
) -> Self
pub fn from_corners( a: Point3<f32>, b: Point3<f32>, c: Point3<f32>, d: Point3<f32>, ) -> Self
Creates a rectangle from four corner points.
The winding order should be: a -> b -> c -> d (counter-clockwise).
Internally computes u = b - a and v = d - a.
§Panics (debug builds only)
Panics if the points are not coplanar.
Sourcepub fn vertices(&self) -> [Point3<f32>; 4]
pub fn vertices(&self) -> [Point3<f32>; 4]
Returns the four vertices of the rectangle.
Order: origin, origin+u, origin+u+v, origin+v (counter-clockwise).
Sourcepub fn normal(&self) -> Vector3<f32>
pub fn normal(&self) -> Vector3<f32>
Computes the (unnormalized) normal vector of the rectangle.
The direction follows the right-hand rule: u × v.
Sourcepub fn unit_normal(&self) -> Option<Vector3<f32>>
pub fn unit_normal(&self) -> Option<Vector3<f32>>
Computes the unit normal vector of the rectangle.
Returns None if the rectangle is degenerate (zero area).
Sourcepub fn plane(&self) -> Plane3D
pub fn plane(&self) -> Plane3D
Returns the plane that this rectangle lies on.
§Panics
Panics if the rectangle is degenerate (u and v are parallel).
Sourcepub fn classify(&self, plane: &Plane3D) -> Classification
pub fn classify(&self, plane: &Plane3D) -> Classification
Classifies this rectangle relative to a plane.
Returns:
Frontif all vertices are in front of the planeBackif all vertices are behind the planeCoplanarif all vertices lie on the planeSpanningif vertices are on both sides
Trait Implementations§
impl StructuralPartialEq for Rectangle
Auto Trait Implementations§
impl Freeze for Rectangle
impl RefUnwindSafe for Rectangle
impl Send for Rectangle
impl Sync for Rectangle
impl Unpin for Rectangle
impl UnsafeUnpin for Rectangle
impl UnwindSafe for Rectangle
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,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.