Struct SourceCollection

Source
pub struct SourceCollection<S: Source<T>, T: Float> { /* private fields */ }
Expand description

Stack-allocated collection of a single source type.

§Fields

  • position: Center of the collection (m), where the children reference.
  • orientation: Orientation of the collection, where the children reference.
  • children: An ordered-vec of homogeneous magnetic sources.

§Example

use magba::sources::*;
use nalgebra::*;

let magnet = CylinderMagnet::<f64>::default();
let mut collection = SourceCollection::default();
collection.add(magnet);

Implementations§

Source§

impl<S: Source<T>, T: Float> SourceCollection<S, T>

Source

pub fn new( position: Point3<T>, orientation: UnitQuaternion<T>, sources: Vec<S>, ) -> Self

Initialize SourceCollection.

Source

pub fn from_sources(sources: Vec<S>) -> Self

Initialize SourceCollection from a vec of homogeneous Source.

Source

pub fn add(&mut self, source: S)

Add Source to the collection.

Source

pub fn add_sources(&mut self, source: &mut Vec<S>)

Add multiple Source to the collection.

Trait Implementations§

Source§

impl<S: Debug + Source<T>, T: Debug + Float> Debug for SourceCollection<S, T>

Source§

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

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

impl<S: Source<T>, T: Float> Default for SourceCollection<S, T>

Source§

fn default() -> Self

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

impl<S: Source<T>, T: Float> Display for SourceCollection<S, T>

Source§

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

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

impl<S: Source<T>, T: Float> Field<T> for SourceCollection<S, T>

Source§

fn get_B(&self, points: &[Point3<T>]) -> Vec<Vector3<T>>

Compute the magnetic field (B) at the given points. Read more
Source§

impl<S: Source<T> + PartialEq, T: Float> PartialEq for SourceCollection<S, T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: Source<T>, T: Float> Transform<T> for SourceCollection<S, T>

Source§

fn position(&self) -> Point3<T>

Get the object position.
Source§

fn orientation(&self) -> UnitQuaternion<T>

Get the object orientation.
Source§

fn set_position(&mut self, position: Point3<T>)

Set the object position.
Source§

fn set_orientation(&mut self, orientation: UnitQuaternion<T>)

Set the object orientation.
Source§

fn translate(&mut self, translation: &Translation3<T>)

Translate the object.
Source§

fn rotate(&mut self, rotation: &UnitQuaternion<T>)

Rotate the object.
Source§

fn rotate_anchor(&mut self, rotation: &UnitQuaternion<T>, anchor: &Point3<T>)

Rotate the object using the anchor point as the center of rotation.
Source§

impl<S: Source<T>, T: Float> Source<T> for SourceCollection<S, T>

Auto Trait Implementations§

§

impl<S, T> Freeze for SourceCollection<S, T>
where T: Freeze,

§

impl<S, T> RefUnwindSafe for SourceCollection<S, T>

§

impl<S, T> Send for SourceCollection<S, T>

§

impl<S, T> Sync for SourceCollection<S, T>

§

impl<S, T> Unpin for SourceCollection<S, T>
where S: Unpin, T: Unpin,

§

impl<S, T> UnwindSafe for SourceCollection<S, T>
where S: UnwindSafe, T: 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

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

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.