Add is_finite to array and quaternion
This commit is contained in:
parent
f82e421e2c
commit
f8e92ed327
4 changed files with 17 additions and 7 deletions
|
@ -118,6 +118,10 @@ macro_rules! impl_point {
|
||||||
fn product(self) -> S where S: Mul<Output = S> {
|
fn product(self) -> S where S: Mul<Output = S> {
|
||||||
fold_array!(mul, { $(self.$field),+ })
|
fold_array!(mul, { $(self.$field),+ })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_finite(&self) -> bool where S: BaseFloat {
|
||||||
|
$(self.$field.is_finite())&&+
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: NumCast + Copy> $PointN<S> {
|
impl<S: NumCast + Copy> $PointN<S> {
|
||||||
|
|
|
@ -173,6 +173,10 @@ impl<S: BaseFloat> Quaternion<S> {
|
||||||
(self * scale1 + other * scale2) * Rad::sin(theta).recip()
|
(self * scale1 + other * scale2) * Rad::sin(theta).recip()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_finite(&self) -> bool {
|
||||||
|
self.s.is_finite() && self.v.is_finite()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: BaseFloat> Zero for Quaternion<S> {
|
impl<S: BaseFloat> Zero for Quaternion<S> {
|
||||||
|
|
|
@ -87,6 +87,11 @@ where
|
||||||
fn product(self) -> Self::Element
|
fn product(self) -> Self::Element
|
||||||
where
|
where
|
||||||
Self::Element: Mul<Output = <Self as Array>::Element>;
|
Self::Element: Mul<Output = <Self as Array>::Element>;
|
||||||
|
|
||||||
|
/// Whether all elements of the array are finite
|
||||||
|
fn is_finite(&self) -> bool
|
||||||
|
where
|
||||||
|
Self::Element: BaseFloat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Element-wise arithmetic operations. These are supplied for pragmatic
|
/// Element-wise arithmetic operations. These are supplied for pragmatic
|
||||||
|
|
|
@ -118,13 +118,6 @@ macro_rules! impl_vector {
|
||||||
$VectorN::new($($field),+)
|
$VectorN::new($($field),+)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: BaseFloat> $VectorN<S> {
|
|
||||||
/// True if all entries in the vector are finite
|
|
||||||
pub fn is_finite(&self) -> bool {
|
|
||||||
$(self.$field.is_finite())&&+
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<S: NumCast + Copy> $VectorN<S> {
|
impl<S: NumCast + Copy> $VectorN<S> {
|
||||||
/// Component-wise casting to another type.
|
/// Component-wise casting to another type.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -170,6 +163,10 @@ macro_rules! impl_vector {
|
||||||
fn product(self) -> S where S: Mul<Output = S> {
|
fn product(self) -> S where S: Mul<Output = S> {
|
||||||
fold_array!(mul, { $(self.$field),+ })
|
fold_array!(mul, { $(self.$field),+ })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_finite(&self) -> bool where S: BaseFloat {
|
||||||
|
$(self.$field.is_finite())&&+
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: BaseNum> Zero for $VectorN<S> {
|
impl<S: BaseNum> Zero for $VectorN<S> {
|
||||||
|
|
Loading…
Reference in a new issue