Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Functions often used to design fields.
Synopsis
- logisticRamp :: Double -> Double -> Double -> Double
- smoothstep :: Double -> Double -> Double -> Double
- gaussianFalloff :: Double -> Double -> Double -> Double
- logisticFalloff :: Double -> Double -> Double -> Double
- cauchyFalloff :: Double -> Double -> Double -> Double
- smoothBump :: Double -> Double
Ramps
Ramps vary from 0 to 1 over their ramping interval.
:: Double | Center \(\mu\) |
-> Double | Wideness \(\beta\) of the transition. Higher is wider. |
-> Double | |
-> Double |
Logistic sigmoid function, varying smoothly from 0 to 1 along the real axis.
Solution to the logistic equation \(y'(x) = -\frac1\beta y(x) \left(1-y(x)\right)\) shifted by \(\mu\).
\[ f_{\mu,\beta}(x) = \frac{1}{1+\exp\left(-\frac{x-\mu}\beta\right)} \]
Smoothstep function, varying symmetrically from 0 to 1 between its parameters. It should be called smoothstepRamp to follow this module’s nomenclature, but the name smoothstep is very much standard.
Falloffs and bumps
Falloffs are bounded functions with \(f(0)=1\) that asymptotically reach 0. Bumps are falloffs that reach 0 in finite distance.
Gaussian falloff. Equivalent to the Gaussian distribution, but normalized to \(f(\mu)=1\), \(\int = \sigma\sqrt{2\pi}\).
\[ f_{\mu,\sigma}(x) = \exp\left(-\frac12\left(\frac{x-\mu}\sigma\right)^2\right) \]
Logistic distribution, normalized to normalized to \(f(\mu)=1\), (int = beta). Compared to a Gaussian falloff, this has a heavier tail (higher kurtosis).
\[ f_{\mu,\beta}(x) = \frac{\exp\left(-\frac{x-\mu}\beta\right)}{\left(1+\exp\left(-\frac{x-\mu}\beta\right)\right)^2} \]
Cauchy falloff. This is a much gentler (quadratic) falloff than Gaussian (exponential). Normalized to \(f(\mu)=1\), \(\int = \pi\gamma\). Its falloff is in fact so slow that it does not have a standard deviation (or any higher moments, for that matter).
\[ f_{\mu,\gamma}(x) = \frac1{1 + \left(\frac{x-\mu}\gamma\right)^2} \]
smoothBump :: Double -> Double Source #
Smooth bump function: nonzero between -1 and 1, smooth over all of \(\mathbb R\).
\[ f(x) = \begin{cases} \exp \left(-{\frac1{1-x^2}}\right) & x \in (-1,1) \\ 0 & \text{otherwise} \end{cases} \]