pub struct BoundingSphere {
pub center: Vector,
pub radius: f32,
}Expand description
Bounding Sphere
Represents a 3D sphere defined by center and radius. Often used for fast collision detection and culling.
Fields§
§center: VectorCenter of the sphere
radius: f32Radius of the sphere
Implementations§
Source§impl BoundingSphere
impl BoundingSphere
Sourcepub fn from_box(bbox: BoundingBox) -> Self
pub fn from_box(bbox: BoundingBox) -> Self
Create a bounding sphere from a bounding box
Sourcepub fn from_points(points: &[Vector]) -> Self
pub fn from_points(points: &[Vector]) -> Self
Create a bounding sphere that encompasses all given points
Sourcepub fn contains_point(self, point: Vector) -> bool
pub fn contains_point(self, point: Vector) -> bool
Check if a point is inside the sphere
Sourcepub fn contains_sphere(self, other: BoundingSphere) -> bool
pub fn contains_sphere(self, other: BoundingSphere) -> bool
Check if another sphere is completely inside this one
Sourcepub fn intersects_sphere(self, other: BoundingSphere) -> bool
pub fn intersects_sphere(self, other: BoundingSphere) -> bool
Check if this sphere intersects with another sphere
Sourcepub fn intersects_box(self, bbox: BoundingBox) -> bool
pub fn intersects_box(self, bbox: BoundingBox) -> bool
Check if this sphere intersects with a bounding box
Sourcepub fn transform(self, transform: Transform) -> Self
pub fn transform(self, transform: Transform) -> Self
Transform the bounding sphere by the given transform
Sourcepub fn distance_to_point(self, point: Vector) -> f32
pub fn distance_to_point(self, point: Vector) -> f32
Get the distance from a point to the sphere surface (negative if inside)
Sourcepub fn expand_to_include(self, point: Vector) -> Self
pub fn expand_to_include(self, point: Vector) -> Self
Expand the sphere to include a point
Sourcepub fn expand_to_include_sphere(self, other: BoundingSphere) -> Self
pub fn expand_to_include_sphere(self, other: BoundingSphere) -> Self
Expand the sphere to include another sphere
Trait Implementations§
Source§impl BinarySerializable for BoundingSphere
impl BinarySerializable for BoundingSphere
Source§impl Clone for BoundingSphere
impl Clone for BoundingSphere
Source§fn clone(&self) -> BoundingSphere
fn clone(&self) -> BoundingSphere
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BoundingSphere
impl Debug for BoundingSphere
Source§impl<'de> Deserialize<'de> for BoundingSphere
impl<'de> Deserialize<'de> for BoundingSphere
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
Source§impl Display for BoundingSphere
impl Display for BoundingSphere
Source§impl PartialEq for BoundingSphere
impl PartialEq for BoundingSphere
Source§impl Serialize for BoundingSphere
impl Serialize for BoundingSphere
impl Copy for BoundingSphere
impl StructuralPartialEq for BoundingSphere
Auto Trait Implementations§
impl Freeze for BoundingSphere
impl RefUnwindSafe for BoundingSphere
impl Send for BoundingSphere
impl Sync for BoundingSphere
impl Unpin for BoundingSphere
impl UnwindSafe for BoundingSphere
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