pub struct RealVec3 {
pub x: f64,
pub y: f64,
pub z: f64,
}Expand description
A vector with three components.
§Examples
use laddu_physics::vectors::RealVec3;
let cross = RealVec3::x().cross(&RealVec3::y());
assert_eq!(cross, RealVec3::z());Fields§
§x: f64The x-component of the vector
y: f64The y-component of the vector
z: f64The z-component of the vector
Implementations§
Source§impl RealVec3
impl RealVec3
Sourcepub fn with_mass(&self, mass: f64) -> RealVec4
pub fn with_mass(&self, mass: f64) -> RealVec4
Create a RealVec4 with this vector as the 3-momentum and the given mass
Sourcepub fn with_energy(&self, energy: f64) -> RealVec4
pub fn with_energy(&self, energy: f64) -> RealVec4
Create a RealVec4 with this vector as the 3-momentum and the given energy
Sourcepub fn dot(&self, other: &RealVec3) -> f64
pub fn dot(&self, other: &RealVec3) -> f64
Compute the dot product of this RealVec3 and another
Sourcepub fn cross(&self, other: &RealVec3) -> RealVec3
pub fn cross(&self, other: &RealVec3) -> RealVec3
Compute the cross product of this RealVec3 and another
Sourcepub fn costheta(&self) -> LadduPhysicsResult<f64>
pub fn costheta(&self) -> LadduPhysicsResult<f64>
The cosine of the polar angle $\theta$
§Errors
Returns LadduPhysicsError when the vector has zero or invalid
magnitude.
Sourcepub fn theta(&self) -> LadduPhysicsResult<f64>
pub fn theta(&self) -> LadduPhysicsResult<f64>
The polar angle $\theta$
§Errors
Returns LadduPhysicsError when the vector has zero or invalid
magnitude.
Sourcepub fn unit(&self) -> LadduPhysicsResult<RealVec3>
pub fn unit(&self) -> LadduPhysicsResult<RealVec3>
Create a unit vector in the same direction as this RealVec3
§Errors
Returns LadduPhysicsError when the vector has zero or invalid
magnitude.
Trait Implementations§
Source§impl AbsDiffEq for RealVec3
impl AbsDiffEq for RealVec3
Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
The default tolerance to use when testing values that are close together. Read more
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
A test for equality that uses the absolute difference to compute the approximate
equality of two numbers.
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of
AbsDiffEq::abs_diff_eq.impl Copy for RealVec3
Source§impl<'de> Deserialize<'de> for RealVec3
impl<'de> Deserialize<'de> for RealVec3
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 RelativeEq for RealVec3
impl RelativeEq for RealVec3
Source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
Source§fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
A test for equality that uses a relative comparison if the values are far apart.
Source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
The inverse of
RelativeEq::relative_eq.impl StructuralPartialEq for RealVec3
Auto Trait Implementations§
impl Freeze for RealVec3
impl RefUnwindSafe for RealVec3
impl Send for RealVec3
impl Sync for RealVec3
impl Unpin for RealVec3
impl UnsafeUnpin for RealVec3
impl UnwindSafe for RealVec3
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ClosedNeg for Twhere
T: Neg<Output = T>,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.