diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-01-10 16:45:27 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-10 16:45:27 -0600 |
| commit | 0d16f01571ec8315f3979eae46981e559ade1cf9 (patch) | |
| tree | ea43c32a57b0e6a67579d75a134dfbc009d09781 /azalea-core/src/math.rs | |
| parent | 615d8f9d2ac56b3244d328587243301da253eafd (diff) | |
| download | azalea-drasl-0d16f01571ec8315f3979eae46981e559ade1cf9.tar.xz | |
Fluid physics (#199)
* start implementing fluid physics
* Initial implementation of fluid pushing
* different travel function in water
* bubble columns
* jumping in water
* cleanup
* change ultrawarm to be required
* fix for clippy
Diffstat (limited to 'azalea-core/src/math.rs')
| -rw-r--r-- | azalea-core/src/math.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/azalea-core/src/math.rs b/azalea-core/src/math.rs index 67ece5cc..a763fc49 100644 --- a/azalea-core/src/math.rs +++ b/azalea-core/src/math.rs @@ -86,6 +86,25 @@ pub fn to_degrees(radians: f64) -> f64 { radians * 57.29577951308232 } +/// Returns either -1, 0, or 1, depending on whether the number is negative, +/// zero, or positive. +/// +/// This function exists because f64::signum doesn't check for 0. +pub fn sign(num: f64) -> f64 { + if num == 0. { + 0. + } else { + num.signum() + } +} +pub fn sign_as_int(num: f64) -> i32 { + if num == 0. { + 0 + } else { + num.signum() as i32 + } +} + #[cfg(test)] mod tests { use super::*; |
