use crate::PhysicsError;
pub use crate::quantities::si_primitives::{Area, Frequency, Length, Mass, Speed, Volume};
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct Acceleration<R: deep_causality_algebra::RealField>(R);
impl<R: deep_causality_algebra::RealField> Default for Acceleration<R> {
fn default() -> Self {
Self(R::zero())
}
}
impl<R: deep_causality_algebra::RealField> Acceleration<R> {
pub fn new(val: R) -> Result<Self, PhysicsError> {
if !val.is_finite() {
return Err(PhysicsError::PhysicalInvariantBroken(
"Acceleration must be finite".into(),
));
}
Ok(Self(val))
}
pub fn new_unchecked(val: R) -> Self {
Self(val)
}
pub fn value(&self) -> R {
self.0
}
}
impl<R: deep_causality_algebra::RealField + Into<f64>> From<Acceleration<R>> for f64 {
fn from(val: Acceleration<R>) -> Self {
val.0.into()
}
}
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct Force<R: deep_causality_algebra::RealField>(R);
impl<R: deep_causality_algebra::RealField> Default for Force<R> {
fn default() -> Self {
Self(R::zero())
}
}
impl<R: deep_causality_algebra::RealField> Force<R> {
pub fn new(val: R) -> Result<Self, PhysicsError> {
if !val.is_finite() {
return Err(PhysicsError::PhysicalInvariantBroken(
"Force must be finite".into(),
));
}
Ok(Self(val))
}
pub fn new_unchecked(val: R) -> Self {
Self(val)
}
pub fn value(&self) -> R {
self.0
}
}
impl<R: deep_causality_algebra::RealField + Into<f64>> From<Force<R>> for f64 {
fn from(val: Force<R>) -> Self {
val.0.into()
}
}
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct Torque<R: deep_causality_algebra::RealField>(R);
impl<R: deep_causality_algebra::RealField> Default for Torque<R> {
fn default() -> Self {
Self(R::zero())
}
}
impl<R: deep_causality_algebra::RealField> Torque<R> {
pub fn new(val: R) -> Result<Self, PhysicsError> {
if !val.is_finite() {
return Err(PhysicsError::PhysicalInvariantBroken(
"Torque must be finite".into(),
));
}
Ok(Self(val))
}
pub fn new_unchecked(val: R) -> Self {
Self(val)
}
pub fn value(&self) -> R {
self.0
}
}
impl<R: deep_causality_algebra::RealField + Into<f64>> From<Torque<R>> for f64 {
fn from(val: Torque<R>) -> Self {
val.0.into()
}
}
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct MomentOfInertia<R: deep_causality_algebra::RealField>(R);
impl<R: deep_causality_algebra::RealField> Default for MomentOfInertia<R> {
fn default() -> Self {
Self(R::zero())
}
}
impl<R: deep_causality_algebra::RealField> MomentOfInertia<R> {
pub fn new(val: R) -> Result<Self, PhysicsError> {
if !val.is_finite() {
return Err(PhysicsError::PhysicalInvariantBroken(
"MomentOfInertia must be finite".into(),
));
}
if val < R::zero() {
return Err(PhysicsError::PhysicalInvariantBroken(
"MomentOfInertia cannot be negative".into(),
));
}
Ok(Self(val))
}
pub fn new_unchecked(val: R) -> Self {
Self(val)
}
pub fn value(&self) -> R {
self.0
}
}
impl<R: deep_causality_algebra::RealField + Into<f64>> From<MomentOfInertia<R>> for f64 {
fn from(val: MomentOfInertia<R>) -> Self {
val.0.into()
}
}