noise_functions/modifiers/
sin.rs

1#[cfg(feature = "nightly-simd")]
2use core::simd::{LaneCount, Simd, SupportedLaneCount};
3
4use crate::{math::sin, Noise, Sample};
5
6/// Computes the sine of the output value (in radians).
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
8pub struct Sin<A> {
9    pub noise: A,
10}
11
12impl<N> Noise for Sin<N> {}
13
14impl<const DIM: usize, N> Sample<DIM> for Sin<N>
15where
16    N: Sample<DIM>,
17{
18    #[inline]
19    fn sample_with_seed(&self, point: [f32; DIM], seed: i32) -> f32 {
20        sin(self.noise.sample_with_seed(point, seed))
21    }
22}
23
24#[cfg(feature = "nightly-simd")]
25impl<const DIM: usize, const LANES: usize, N> Sample<DIM, Simd<f32, LANES>> for Sin<N>
26where
27    N: Sample<DIM, Simd<f32, LANES>>,
28    LaneCount<LANES>: SupportedLaneCount,
29{
30    #[inline]
31    fn sample_with_seed(&self, point: Simd<f32, LANES>, seed: i32) -> f32 {
32        sin(self.noise.sample_with_seed(point, seed))
33    }
34}