Add Transform::is_finite (#10592)

# Objective

- Sometimes it's very useful to know if a `Transform` contains any `NaN`
or infinite values. It's a bit boiler-plate heavy to check translation,
rotation and scale individually.

## Solution

- Add a new method `is_finite` that returns true if, and only if
translation, rotation and scale all are finite.
- It's a natural extension of `Quat::is_finite`, and `Vec3::is_finite`,
which return true if, and only if all their components' `is_finite()`
returns true.

---

## Changelog

- Added `Transform::is_finite`
This commit is contained in:
Johan Klokkhammer Helsing 2023-11-20 10:42:57 +01:00 committed by GitHub
parent 78c255f9c9
commit ef50b3c9f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -396,6 +396,15 @@ impl Transform {
point += self.translation;
point
}
/// Returns `true` if, and only if, translation, rotation and scale all are
/// finite. If any of them contains a `NaN`, positive or negative infinity,
/// this will return `false`.
#[inline]
#[must_use]
pub fn is_finite(&self) -> bool {
self.translation.is_finite() && self.rotation.is_finite() && self.scale.is_finite()
}
}
impl Default for Transform {