5 Commits

Author SHA1 Message Date
33b335f987 what if do like this - wait idk 2024-08-28 14:09:44 -07:00
c9b999b8a6 can't get rid of the double pattern match not knowing which repeated variable to loop 2024-08-28 13:49:56 -07:00
23a6ffb243 wip transpose 2024-08-28 13:49:56 -07:00
9ef9b5ff3f traits 2024-08-28 13:49:56 -07:00
c277c31f29 wip 2024-08-28 13:49:56 -07:00
4 changed files with 46 additions and 0 deletions
fixed_wide_vectors/src

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

@ -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 {

@ -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;
}

@ -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);