Struct vek::geom::repr_c::Sphere

source ·
pub struct Sphere<P, E> {
    pub center: Vec3<P>,
    pub radius: E,
}
Expand description

Sphere (3D), represented by center and radius.

Fields§

§center: Vec3<P>§radius: E

Implementations§

source§

impl<P, E> Sphere<P, E>

source

pub fn surface_area(self) -> E
where E: Copy + One + FloatConst + Add<Output = E> + Mul<Output = E>,

Gets this sphere’s surface area.

source

pub fn volume(self) -> E
where E: Copy + One + FloatConst + Add<Output = E> + Mul<Output = E> + Div<Output = E>,

Gets this sphere’s volume.

source§

impl<P, E> Sphere<P, E>

source

pub fn new(center: Vec3<P>, radius: E) -> Self

Creates a new Sphere from center and radius.

source

pub fn unit(center: Vec3<P>) -> Self
where E: One,

Creates a new Sphere from center and a radius equal to one.

source

pub fn point(center: Vec3<P>) -> Self
where E: Zero,

Creates a new Sphere from center and a radius equal to zero.

source

pub fn diameter(self) -> E
where E: Copy + Add<Output = E>,

Gets the value of twice the radius.

source

pub fn rect3(self) -> Rect3<P, E>
where P: Sub<P, Output = P> + From<E> + Copy, E: Copy + Add<E, Output = E>,

Gets the bounding rectangle for this shape.

source§

impl<T> Sphere<T, T>
where T: Copy + Add<T, Output = T> + Sub<T, Output = T>,

source

pub fn aabb(self) -> Aabb<T>

Gets this shape’s bounds.

source§

impl<T: Real + Add<T, Output = T>> Sphere<T, T>

source

pub fn contains_point(self, p: Vec3<T>) -> bool
where T: PartialOrd,

Does this shape contain the given point ?

source

pub fn collides_with_sphere(self, other: Self) -> bool
where T: PartialOrd,

Does this shape collide with another ?

source

pub fn collision_vector_with_sphere(self, other: Self) -> Vec3<T>

Gets a vector that tells how much this shape penetrates another.

Trait Implementations§

source§

impl<P: Clone, E: Clone> Clone for Sphere<P, E>

source§

fn clone(&self) -> Sphere<P, E>

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<P: Debug, E: Debug> Debug for Sphere<P, E>

source§

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

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

impl<P: Default, E: Default> Default for Sphere<P, E>

source§

fn default() -> Sphere<P, E>

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

impl<'de, P, E> Deserialize<'de> for Sphere<P, E>
where P: Deserialize<'de>, E: Deserialize<'de>,

source§

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<P: Hash, E: Hash> Hash for Sphere<P, E>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<P: PartialEq, E: PartialEq> PartialEq for Sphere<P, E>

source§

fn eq(&self, other: &Sphere<P, E>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<P, E> Serialize for Sphere<P, E>
where P: Serialize, E: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<P: Copy, E: Copy> Copy for Sphere<P, E>

source§

impl<P: Eq, E: Eq> Eq for Sphere<P, E>

source§

impl<P, E> StructuralPartialEq for Sphere<P, E>

Auto Trait Implementations§

§

impl<P, E> Freeze for Sphere<P, E>
where E: Freeze, P: Freeze,

§

impl<P, E> RefUnwindSafe for Sphere<P, E>

§

impl<P, E> Send for Sphere<P, E>
where E: Send, P: Send,

§

impl<P, E> Sync for Sphere<P, E>
where E: Sync, P: Sync,

§

impl<P, E> Unpin for Sphere<P, E>
where E: Unpin, P: Unpin,

§

impl<P, E> UnwindSafe for Sphere<P, E>
where E: UnwindSafe, P: UnwindSafe,

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> 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,

§

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>,

§

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>,

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,