Compare commits

...

4 Commits

Author SHA1 Message Date
6f99aa5385 note usefulness 2026-01-12 11:51:04 -08:00
bad895ef54 rename to absolute 2026-01-12 11:49:37 -08:00
41a02e7b3c notes 2025-11-27 15:07:24 -08:00
4637891a21 euclidean point 2025-11-27 15:06:18 -08:00
2 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
/// Euclidean point.
/// Newtype of ideal point.
/// Euclidean points can be offset by ideal points to create a new euclidean point.
/// Two euclidean points cannot be added together.
/// Subtracting two euclidean points gives an ideal point.
// TODO: Affine*Point translates but Affine*Vector does not translate
// This can be used for both Position and Time
pub struct Absolute<P>(P);
use core::ops::Add;
use core::ops::Sub;
use core::ops::AddAssign;
use core::ops::SubAssign;
// Offset euclidean point by ideal point
impl<P:Add> Add<P> for Absolute<P>{
type Output=Absolute<P::Output>;
fn add(self,rhs:P)->Self::Output{
Absolute(self.0+rhs)
}
}
impl<P:Sub> Sub<P> for Absolute<P>{
type Output=Absolute<P::Output>;
fn sub(self,rhs:P)->Self::Output{
Absolute(self.0-rhs)
}
}
impl<P:AddAssign> AddAssign<P> for Absolute<P>{
fn add_assign(&mut self,rhs:P){
self.0+=rhs;
}
}
impl<P:SubAssign> SubAssign<P> for Absolute<P>{
fn sub_assign(&mut self,rhs:P){
self.0-=rhs;
}
}
// Extract ideal point from euclidean point
impl<P:Sub> Sub for Absolute<P>{
type Output=P::Output;
fn sub(self,rhs:Absolute<P>)->Self::Output{
self.0-rhs.0
}
}

View File

@@ -5,6 +5,7 @@ pub mod run;
pub mod aabb;
pub mod model;
pub mod mouse;
pub mod euclidean_point;
pub mod timer;
pub mod integer;
pub mod physics;