Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
33b335f987 | |||
c9b999b8a6 | |||
23a6ffb243 | |||
9ef9b5ff3f | |||
c277c31f29 |
@ -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 {
|
||||||
|
8
fixed_wide_vectors/src/traits.rs
Normal file
8
fixed_wide_vectors/src/traits.rs
Normal 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;
|
||||||
|
}
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user