Skip to main content

steel_math/noise_math/
mod.rs

1mod coordinate;
2mod gradient;
3mod interpolation;
4
5use core::f64::consts::PI;
6
7pub use coordinate::{fast_floor, fast_floor_simd, fast_lfloor, wrap, wrap_simd};
8pub use gradient::{GRADIENT, GRADIENT_F32, corner_noise_3d, dot, grad_dot, grad_dot_simd};
9pub use interpolation::{
10    clamp, clamp_i32, clamped_lerp, clamped_lerp_simd, inverse_lerp, lerp, lerp_simd, lerp2,
11    lerp2_simd, lerp3, lerp3_simd, map, map_clamped, smoothstep, smoothstep_derivative,
12    smoothstep_simd,
13};
14
15/// Bias a noise value towards extremes (-1 or 1) using a sine curve.
16///
17/// Java reference: `NoiseUtils.biasTowardsExtreme(double, double)`
18#[inline]
19#[must_use]
20pub fn bias_towards_extreme(noise: f64, factor: f64) -> f64 {
21    noise + (PI * noise).sin() * factor / PI
22}
23
24/// Cube a value.
25#[inline]
26#[must_use]
27pub fn cube(x: f64) -> f64 {
28    x * x * x
29}
30
31/// Square a value.
32#[inline]
33#[must_use]
34pub fn square(x: f64) -> f64 {
35    x * x
36}