Compare commits

...

5 Commits

4 changed files with 46 additions and 0 deletions

View File

@ -1,4 +1,5 @@
mod macros; mod macros;
mod traits;
mod vector; mod vector;
#[cfg(feature="fixed_wide_traits")] #[cfg(feature="fixed_wide_traits")]

View File

@ -251,6 +251,38 @@ macro_rules! impl_vector {
} }
#[doc(hidden)]
#[macro_export(local_inner_macros)]
macro_rules! impl_matrix_inner {
( $struct_outer: ident { $($field_outer: ident), + }, $size_outer: expr,
$field_inner: ident) => {
$struct_outer {
$(
$field_outer: self.$field_outer.$field_inner
),+
}
}
}
#[doc(hidden)]
#[macro_export(local_inner_macros)]
macro_rules! impl_matrix {
( $struct_outer: ident { $($field_outer: ident),+ }, $size_outer: expr) => {
impl<T> Transpose for $struct_outer<$struct_inner<T>> {
fn transpose(self) -> $struct_inner<$struct_outer<T>> {
$struct_inner {
$(
$field_inner: impl_matrix_inner!(
Vector2{x,y}, $size_outer,
$field_inner
)
),+
}
}
}
}
}
#[doc(hidden)] #[doc(hidden)]
#[macro_export(local_inner_macros)] #[macro_export(local_inner_macros)]
macro_rules! impl_operator { macro_rules! impl_operator {

View File

@ -0,0 +1,8 @@
pub trait Dot<Rhs=Self>{
type Output;
fn dot(self,rhs:Rhs)->Self::Output;
}
pub trait Transpose{
type Output;
fn transpose(self)->Self::Output;
}

View File

@ -66,3 +66,8 @@ pub struct Vector4<T> {
crate::impl_vector!(Vector2 { x, y }, (T, T), 2); crate::impl_vector!(Vector2 { x, y }, (T, T), 2);
crate::impl_vector!(Vector3 { x, y, z }, (T, T, T), 3); crate::impl_vector!(Vector3 { x, y, z }, (T, T, T), 3);
crate::impl_vector!(Vector4 { x, y, z, w }, (T, T, T, T), 4); crate::impl_vector!(Vector4 { x, y, z, w }, (T, T, T, T), 4);
//This internally implements non square matrices, idk how else to separate the repeated fields
crate::impl_matrix!(Vector2 { x, y }, 2);
crate::impl_matrix!(Vector3 { x, y, z }, 3);
crate::impl_matrix!(Vector4 { x, y, z, w }, 4);