#[repr(C)]
pub struct PointMass<V, S> { pub position: V, pub mass: S, }
Expand description

Point-mass representation of an object in space.

Fields§

§position: V

Position of the object.

§mass: S

Mass of the object.

Implementations§

source§

impl<V: Zero, S: Zero> PointMass<V, S>

source

pub const ZERO: Self = _

PointMass with position and mass set to Zero::ZERO.

source§

impl<V, S> PointMass<V, S>

source

pub const fn new(position: V, mass: S) -> Self

Creates a new PointMass with the given position and mass.

source

pub fn new_lane(position: V::Lane, mass: S::Lane) -> Self
where V: SIMD, S: SIMD,

Creates a new PointMass with the given lanes of positions and masses.

source

pub fn new_com(data: &[Self]) -> Self
where V: FloatVector<Float = S> + Sum + Copy, S: Float + FromPrimitive<usize> + Sum + Copy,

Returns the PointMass corresponding to the center of mass and total mass of the given slice of point-masses.

source

pub fn splat_lane(position: V::Element, mass: S::Element) -> Self
where V: SIMD, S: SIMD,

Creates a new PointMass with all lanes set to the given position and mass.

source

pub fn slice_to_lane<const L: usize, T, E>(slice: &[PointMass<T, E>]) -> Self
where T: Clone + Zero, E: Clone + Zero, V: SIMD<Lane = [T; L], Element = T>, S: SIMD<Lane = [E; L], Element = E>,

Returns a SIMD point-masses from a slice of SIMD::Element point-masses.

source

pub fn slice_to_lanes<'a, const L: usize, T, E>( slice: &'a [PointMass<T, E>] ) -> impl Iterator<Item = Self> + 'a
where T: Clone + Zero, E: Clone + Zero, V: SIMD<Lane = [T; L], Element = T> + 'a, S: SIMD<Lane = [E; L], Element = E> + 'a,

Returns an iterator of SIMD point-masses from a slice of SIMD::Element point-masses.

source

pub fn is_massless(&self) -> bool
where S: PartialEq + Zero,

Returns true if the mass is zero.

source

pub fn is_massive(&self) -> bool
where S: PartialEq + Zero,

Returns false if the mass is zero.

source

pub fn force_scalar<const CHECK_ZERO: bool>( &self, position: V, mass: S, softening: S ) -> V
where V: FloatVector<Float = S> + Copy, S: Float + Copy,

Computes the gravitational force exerted on the current point-mass using the given position and mass. This method is optimised in the case where V and S are scalar types.

If the position of the current point-mass is guaranteed to be different from the given position, this computation can be more efficient with CHECK_ZERO set to false.

source

pub fn force_simd<const CHECK_ZERO: bool>( &self, position: V, mass: S, softening: S ) -> V
where V: FloatVector<Float = S> + Copy, S: Float + BitAnd<Output = S> + CmpNe<Output = S> + Copy,

Computes the gravitational force exerted on the current point-mass using the given position and mass. This method is optimised in the case where V and S are simd types.

If the position of the current point-mass is guaranteed to be different from the given position, this computation can be more efficient with CHECK_ZERO set to false.

source

pub fn acceleration_tree<const X: usize, const D: usize>( &self, tree: &Orthtree<X, D, S, PointMass<V, S>>, node: Option<NodeID>, theta: S, softening: S ) -> V
where V: FloatVector<Float = S> + Copy + Sum, S: Float + PartialOrd + Copy,

Computes the gravitational acceleration exerted on the current point-mass by the specified node of the given Orthtree following the Barnes-Hut approximation with the given theta parameter, provided V and S are scalar types.

Trait Implementations§

source§

impl<V: Clone, S: Clone> Clone for PointMass<V, S>

source§

fn clone(&self) -> PointMass<V, S>

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<V: Debug, S: Debug> Debug for PointMass<V, S>

source§

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

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

impl<V: Default, S: Default> Default for PointMass<V, S>

source§

fn default() -> PointMass<V, S>

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

impl<V: Zeroable, S: Zeroable> Zeroable for PointMass<V, S>

source§

fn zeroed() -> Self

source§

impl<V: Copy, S: Copy> Copy for PointMass<V, S>

source§

impl<V: NoUninit, S: NoUninit> NoUninit for PointMass<V, S>

Auto Trait Implementations§

§

impl<V, S> Freeze for PointMass<V, S>
where S: Freeze, V: Freeze,

§

impl<V, S> RefUnwindSafe for PointMass<V, S>

§

impl<V, S> Send for PointMass<V, S>
where S: Send, V: Send,

§

impl<V, S> Sync for PointMass<V, S>
where S: Sync, V: Sync,

§

impl<V, S> Unpin for PointMass<V, S>
where S: Unpin, V: Unpin,

§

impl<V, S> UnwindSafe for PointMass<V, S>
where S: UnwindSafe, V: 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<U> AsPrimitive for U

source§

fn as_<F: FromPrimitive<Self>>(self) -> F

Converts this primitive into the input primitive.
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> Downcast<T> for T

source§

fn downcast(&self) -> &T

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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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> Upcast<T> for T

source§

fn upcast(&self) -> Option<&T>

source§

impl<T> WasmNotSend for T
where T: Send,

source§

impl<T> WasmNotSendSync for T

source§

impl<T> WasmNotSync for T
where T: Sync,