vectors: min, max

This commit is contained in:
Quaternions 2024-08-27 14:23:53 -07:00
parent 4ce5c045a8
commit 2d87e4b5cc

View File

@ -166,6 +166,19 @@ macro_rules! impl_vector {
}
}
impl<T: Ord> $struct<T> {
pub fn min(self, rhs: Self) -> $struct<T> {
$struct{
$( $field: self.$field.min(rhs.$field) ), +
}
}
pub fn max(self, rhs: Self) -> $struct<T> {
$struct{
$( $field: self.$field.max(rhs.$field) ), +
}
}
}
impl<T: core::ops::Neg<Output = T>> core::ops::Neg for $struct<T> {
type Output = Self;