From d65fe4035461b8a7a9662547888756ee34ee6fbf Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 30 Aug 2024 13:19:51 -0700 Subject: [PATCH] wip --- fixed_wide_vectors/src/macros/matrix.rs | 4 ++-- fixed_wide_vectors/src/macros/wide.rs | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/fixed_wide_vectors/src/macros/matrix.rs b/fixed_wide_vectors/src/macros/matrix.rs index f9375e7..1cbd791 100644 --- a/fixed_wide_vectors/src/macros/matrix.rs +++ b/fixed_wide_vectors/src/macros/matrix.rs @@ -46,8 +46,8 @@ macro_rules! impl_matrix { } // Impl floating-point based methods - //#[cfg(feature="fixed_wide_traits")] - //$crate::impl_wide_matrix_operations!( ($struct_outer { $($field_outer), + }, $size_outer), ($struct_inner, $size_inner), $fields_inner ); + #[cfg(feature="fixed_wide_traits")] + $crate::impl_wide_matrix_operations!( ($struct_outer { $($field_outer), + }, $size_outer), ($struct_inner, $size_inner), $fields_inner ); }; } diff --git a/fixed_wide_vectors/src/macros/wide.rs b/fixed_wide_vectors/src/macros/wide.rs index e35d51b..b81f06c 100644 --- a/fixed_wide_vectors/src/macros/wide.rs +++ b/fixed_wide_vectors/src/macros/wide.rs @@ -31,7 +31,10 @@ macro_rules! impl_wide_vector_operations { }; } -/* +// Notes: +// Mat3.dot(Vec3) -> Vec2 +// mat.mat can be implemented off the back of mat.vec + #[doc(hidden)] #[macro_export(local_inner_macros)] macro_rules! impl_wide_matrix_operations { @@ -44,11 +47,11 @@ macro_rules! impl_wide_matrix_operations { #[inline] fn wide_mul(self, rhs: Self) -> Self::Output { $struct{ - $( $field: self.$field.wide_mul(rhs.$field) ), + + $( $field_outer: self.$field_outer.wide_mul(rhs.$field_outer) ), + } } } - impl,U,T:fixed_wide_traits::wide::WideMul> fixed_wide_traits::wide::WideDot<$struct> for $struct { + impl> fixed_wide_traits::wide::WideDot<$struct> for $struct { type Output=V; #[inline] fn wide_dot(self, rhs: $struct) -> Self::Output { @@ -57,17 +60,18 @@ macro_rules! impl_wide_matrix_operations { ) } } + /* TODO: nasty determinant macro impl,T:Copy+fixed_wide_traits::wide::WideMul> $struct { #[inline] - pub fn wide_length_squared(&self) -> U { + pub fn wide_det(&self) -> U { $crate::sum_repeating!( $( + self.$field.wide_mul(self.$field) ) + ) } } + */ }; } -*/ // HACK: Allows us to sum repeating tokens in macros. // See: https://stackoverflow.com/a/60187870/17452730