pub struct Force<N: Num, const D: usize> { /* private fields */ }
Expand description
Force<N, D>
structure for D dimension forces
Implementations§
source§impl<N: Copy + Num + Sum, const D: usize> Force<N, D>
impl<N: Copy + Num + Sum, const D: usize> Force<N, D>
sourcepub fn square_norm(&self) -> N
pub fn square_norm(&self) -> N
Returns the squared norm of force
Example
use pythagore::force;
assert_eq!(force!{ dx: 2, dy: 3 }.square_norm(), 13);
assert_eq!(force!{ dx: 2, dy: 3, dz: 4 }.square_norm(), 29);
source§impl<N: Copy + Float + Sum, const D: usize> Force<N, D>
impl<N: Copy + Float + Sum, const D: usize> Force<N, D>
source§impl<N: Copy + Signed + Sum, const D: usize> Force<N, D>
impl<N: Copy + Signed + Sum, const D: usize> Force<N, D>
sourcepub fn manhattan_norm(&self) -> N
pub fn manhattan_norm(&self) -> N
Returns the norm of force (only for signed forces)
Example
use pythagore::force;
assert_eq!(force!{ dx: 1, dy: -2 }.manhattan_norm(), 3);
assert_eq!(force!{ dx: 1, dy: -2, dz: 3 }.manhattan_norm(), 6);
source§impl<N: Copy + Num> Force<N, 4>
impl<N: Copy + Num> Force<N, 4>
sourcepub fn unit_dx() -> Self
pub fn unit_dx() -> Self
Returns dx unit force
Example
use pythagore::{force, Force3D};
assert_eq!(Force3D::unit_dx(), force!{ dx: 1, dy: 0, dz: 0 });
sourcepub fn unit_dy() -> Self
pub fn unit_dy() -> Self
Returns dy unit force
Example
use pythagore::{force, Force3D};
assert_eq!(Force3D::unit_dy(), force!{ dx: 0, dy: 1, dz: 0 });
sourcepub fn unit_dz() -> Self
pub fn unit_dz() -> Self
Returns dz unit force
Example
use pythagore::{force, Force3D};
assert_eq!(Force3D::unit_dz(), force!{ dx: 0, dy: 0, dz: 1 });
sourcepub fn dx(&self) -> &N
pub fn dx(&self) -> &N
Returns ref on dx element of force
Example
use pythagore::force;
assert_eq!(force!{ dx: 1, dy: 2, dz: 3 }.dx(), &1);
sourcepub fn dx_mut(&mut self) -> &mut N
pub fn dx_mut(&mut self) -> &mut N
Returns mutable ref on dx element of force
Example
use pythagore::force;
let mut v = force!{ dx: 1, dy: 2, dz: 3 };
*v.dx_mut() = 5;
assert_eq!(v.dx(), &5);
sourcepub fn dy(&self) -> &N
pub fn dy(&self) -> &N
Returns ref on dy element of force
Example
use pythagore::force;
assert_eq!(force!{ dx: 1, dy: 2, dz: 3 }.dy(), &2);
sourcepub fn dy_mut(&mut self) -> &mut N
pub fn dy_mut(&mut self) -> &mut N
Returns mutable ref on dy element of force
Example
use pythagore::force;
let mut v = force!{ dx: 1, dy: 2, dz: 3 };
*v.dy_mut() = 5;
assert_eq!(v.dy(), &5);
source§impl<N: Copy + Num> Force<N, 3>
impl<N: Copy + Num> Force<N, 3>
sourcepub fn unit_dx() -> Self
pub fn unit_dx() -> Self
Returns dx unit force
Example
use pythagore::{force, Force2D};
assert_eq!(Force2D::unit_dx(), force!{ dx: 1, dy: 0 });
sourcepub fn unit_dy() -> Self
pub fn unit_dy() -> Self
Returns dy unit force
Example
use pythagore::{force, Force2D};
assert_eq!(Force2D::unit_dy(), force!{ dx: 0, dy: 1 });
sourcepub fn dx(&self) -> &N
pub fn dx(&self) -> &N
Returns ref on dx element of force
Example
use pythagore::force;
assert_eq!(force!{ dx: 1, dy: 2 }.dx(), &1);
sourcepub fn dx_mut(&mut self) -> &mut N
pub fn dx_mut(&mut self) -> &mut N
Returns mutable ref on dx element of force
Example
use pythagore::force;
let mut v = force!{ dx: 1, dy: 2 };
*v.dx_mut() = 5;
assert_eq!(v.dx(), &5);
Trait Implementations§
source§impl<N: Copy + Num + AddAssign, const D: usize> AddAssign<&Force<N, D>> for Force<N, D>
impl<N: Copy + Num + AddAssign, const D: usize> AddAssign<&Force<N, D>> for Force<N, D>
source§fn add_assign(&mut self, rhs: &Force<N, D>)
fn add_assign(&mut self, rhs: &Force<N, D>)
Performs the
+=
operation. Read moresource§impl<N: Copy + Num + AddAssign, const D: usize> AddAssign<&Force<N, D>> for Point<N, D>
impl<N: Copy + Num + AddAssign, const D: usize> AddAssign<&Force<N, D>> for Point<N, D>
source§fn add_assign(&mut self, rhs: &Force<N, D>)
fn add_assign(&mut self, rhs: &Force<N, D>)
Performs the
+=
operation. Read moresource§impl<N: Copy + Num + AddAssign, const D: usize> AddAssign<Force<N, D>> for Force<N, D>
impl<N: Copy + Num + AddAssign, const D: usize> AddAssign<Force<N, D>> for Force<N, D>
source§fn add_assign(&mut self, rhs: Force<N, D>)
fn add_assign(&mut self, rhs: Force<N, D>)
Performs the
+=
operation. Read moresource§impl<N: Copy + Num + AddAssign, const D: usize> AddAssign<Force<N, D>> for Point<N, D>
impl<N: Copy + Num + AddAssign, const D: usize> AddAssign<Force<N, D>> for Point<N, D>
source§fn add_assign(&mut self, rhs: Force<N, D>)
fn add_assign(&mut self, rhs: Force<N, D>)
Performs the
+=
operation. Read moresource§impl<N: Copy + Num + DivAssign, const D: usize> DivAssign<&N> for Force<N, D>
impl<N: Copy + Num + DivAssign, const D: usize> DivAssign<&N> for Force<N, D>
source§fn div_assign(&mut self, rhs: &N)
fn div_assign(&mut self, rhs: &N)
Performs the
/=
operation. Read moresource§impl<N: Copy + Num + DivAssign, const D: usize> DivAssign<N> for Force<N, D>
impl<N: Copy + Num + DivAssign, const D: usize> DivAssign<N> for Force<N, D>
source§fn div_assign(&mut self, rhs: N)
fn div_assign(&mut self, rhs: N)
Performs the
/=
operation. Read moresource§impl<N: Copy + Num, const D: usize> FromIterator<N> for Force<N, D>
impl<N: Copy + Num, const D: usize> FromIterator<N> for Force<N, D>
source§fn from_iter<T: IntoIterator<Item = N>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = N>>(iter: T) -> Self
Creates a value from an iterator. Read more
source§impl<N: Copy + Num + MulAssign, const D: usize> MulAssign<&N> for Force<N, D>
impl<N: Copy + Num + MulAssign, const D: usize> MulAssign<&N> for Force<N, D>
source§fn mul_assign(&mut self, rhs: &N)
fn mul_assign(&mut self, rhs: &N)
Performs the
*=
operation. Read moresource§impl<N: Copy + Num + Sum, const D: usize> MulAssign<&Transform<N, D>> for Force<N, D>
impl<N: Copy + Num + Sum, const D: usize> MulAssign<&Transform<N, D>> for Force<N, D>
source§fn mul_assign(&mut self, rhs: &Transform<N, D>)
fn mul_assign(&mut self, rhs: &Transform<N, D>)
Performs the
*=
operation. Read moresource§impl<N: Copy + Num + MulAssign, const D: usize> MulAssign<N> for Force<N, D>
impl<N: Copy + Num + MulAssign, const D: usize> MulAssign<N> for Force<N, D>
source§fn mul_assign(&mut self, rhs: N)
fn mul_assign(&mut self, rhs: N)
Performs the
*=
operation. Read moresource§impl<N: Copy + Num + Sum, const D: usize> MulAssign<Transform<N, D>> for Force<N, D>
impl<N: Copy + Num + Sum, const D: usize> MulAssign<Transform<N, D>> for Force<N, D>
source§fn mul_assign(&mut self, rhs: Transform<N, D>)
fn mul_assign(&mut self, rhs: Transform<N, D>)
Performs the
*=
operation. Read moresource§impl<N: Num, const D: usize> PartialEq<Force<N, D>> for Force<N, D>
impl<N: Num, const D: usize> PartialEq<Force<N, D>> for Force<N, D>
source§impl<N: Copy + Num + SubAssign, const D: usize> SubAssign<&Force<N, D>> for Force<N, D>
impl<N: Copy + Num + SubAssign, const D: usize> SubAssign<&Force<N, D>> for Force<N, D>
source§fn sub_assign(&mut self, rhs: &Force<N, D>)
fn sub_assign(&mut self, rhs: &Force<N, D>)
Performs the
-=
operation. Read moresource§impl<N: Copy + Num + SubAssign, const D: usize> SubAssign<&Force<N, D>> for Point<N, D>
impl<N: Copy + Num + SubAssign, const D: usize> SubAssign<&Force<N, D>> for Point<N, D>
source§fn sub_assign(&mut self, rhs: &Force<N, D>)
fn sub_assign(&mut self, rhs: &Force<N, D>)
Performs the
-=
operation. Read moresource§impl<N: Copy + Num + SubAssign, const D: usize> SubAssign<Force<N, D>> for Force<N, D>
impl<N: Copy + Num + SubAssign, const D: usize> SubAssign<Force<N, D>> for Force<N, D>
source§fn sub_assign(&mut self, rhs: Force<N, D>)
fn sub_assign(&mut self, rhs: Force<N, D>)
Performs the
-=
operation. Read moresource§impl<N: Copy + Num + SubAssign, const D: usize> SubAssign<Force<N, D>> for Point<N, D>
impl<N: Copy + Num + SubAssign, const D: usize> SubAssign<Force<N, D>> for Point<N, D>
source§fn sub_assign(&mut self, rhs: Force<N, D>)
fn sub_assign(&mut self, rhs: Force<N, D>)
Performs the
-=
operation. Read moreimpl<N: Copy + Num, const D: usize> Copy for Force<N, D>
impl<N: Eq + Num, const D: usize> Eq for Force<N, D>
impl<N: Num, const D: usize> StructuralEq for Force<N, D>
Auto Trait Implementations§
impl<N, const D: usize> RefUnwindSafe for Force<N, D>where N: RefUnwindSafe,
impl<N, const D: usize> Send for Force<N, D>where N: Send,
impl<N, const D: usize> Sync for Force<N, D>where N: Sync,
impl<N, const D: usize> Unpin for Force<N, D>where N: Unpin,
impl<N, const D: usize> UnwindSafe for Force<N, D>where N: 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