pub struct Obb2<Unit: Copy = (), Space: Copy = ()> {
pub center: Vec2<Unit, Space>,
pub half_extents: Vec2<Unit, Space>,
pub axis_x: Vec2<Unit, Space>,
pub axis_y: Vec2<Unit, Space>,
}Expand description
A 2D oriented bounding box (OBB).
Stored as a center, half-extents, and an orthonormal basis (axis_x, axis_y).
Fields§
§center: Vec2<Unit, Space>§half_extents: Vec2<Unit, Space>Half-extents along each local axis. Components should be non-negative.
axis_x: Vec2<Unit, Space>Local +X axis (should be unit length).
axis_y: Vec2<Unit, Space>Local +Y axis (should be unit length and orthogonal to axis_x).
Implementations§
Source§impl<Unit: Copy, Space: Copy> Obb2<Unit, Space>
impl<Unit: Copy, Space: Copy> Obb2<Unit, Space>
Sourcepub const fn from_center_half_extents(
center: Vec2<Unit, Space>,
half_extents: Vec2<Unit, Space>,
) -> Self
pub const fn from_center_half_extents( center: Vec2<Unit, Space>, half_extents: Vec2<Unit, Space>, ) -> Self
Creates an axis-aligned OBB (equivalent to an AABB expressed as center + half-extents).
Sourcepub fn from_center_half_extents_rotation_radians(
center: Vec2<Unit, Space>,
half_extents: Vec2<Unit, Space>,
angle: Radians,
) -> Self
pub fn from_center_half_extents_rotation_radians( center: Vec2<Unit, Space>, half_extents: Vec2<Unit, Space>, angle: Radians, ) -> Self
Creates a rotated OBB using a typed angle.
The rotation is counter-clockwise.
Sourcepub fn from_center_half_extents_rotation_deg(
center: Vec2<Unit, Space>,
half_extents: Vec2<Unit, Space>,
angle: Degrees,
) -> Self
pub fn from_center_half_extents_rotation_deg( center: Vec2<Unit, Space>, half_extents: Vec2<Unit, Space>, angle: Degrees, ) -> Self
Creates a rotated OBB using a typed angle in degrees.
Sourcepub fn try_from_axes(
center: Vec2<Unit, Space>,
half_extents: Vec2<Unit, Space>,
axis_x: Vec2<Unit, Space>,
axis_y: Vec2<Unit, Space>,
) -> Option<Self>
pub fn try_from_axes( center: Vec2<Unit, Space>, half_extents: Vec2<Unit, Space>, axis_x: Vec2<Unit, Space>, axis_y: Vec2<Unit, Space>, ) -> Option<Self>
Attempts to create an OBB from basis axes.
Returns None if:
- half-extents are negative or non-finite
- axes are not finite
- axes are not approximately unit length and orthogonal
pub fn contains_point(self, p: Vec2<Unit, Space>) -> bool
pub fn closest_point(self, p: Vec2<Unit, Space>) -> Vec2<Unit, Space>
Trait Implementations§
Source§impl<'de, Unit, Space> Deserialize<'de> for Obb2<Unit, Space>
impl<'de, Unit, Space> Deserialize<'de> for Obb2<Unit, Space>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<Unit: Copy + Copy, Space: Copy + Copy> Copy for Obb2<Unit, Space>
impl<Unit: Copy, Space: Copy> StructuralPartialEq for Obb2<Unit, Space>
Auto Trait Implementations§
impl<Unit, Space> Freeze for Obb2<Unit, Space>
impl<Unit, Space> RefUnwindSafe for Obb2<Unit, Space>where
Unit: RefUnwindSafe,
Space: RefUnwindSafe,
impl<Unit, Space> Send for Obb2<Unit, Space>
impl<Unit, Space> Sync for Obb2<Unit, Space>
impl<Unit, Space> Unpin for Obb2<Unit, Space>
impl<Unit, Space> UnwindSafe for Obb2<Unit, Space>where
Unit: UnwindSafe,
Space: UnwindSafe,
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
Mutably borrows from an owned value. Read more