LoginSignup
15
18

More than 5 years have passed since last update.

smoothstep

Last updated at Posted at 2014-07-13

故あってsmoothstepという関数がなにをしているのか調べてみた。

仕様書によると、Hermite interpolationというのをやってくれるようだ。(読み方がわからない。)

Returns 0.0 if x less than or equal to edge0 and 1.0 if x greater than or equal to edge1 and > performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1. This is useful in cases where you would want a threshold function with a smooth transition.

仕様書通りにJavaで実装してみる。

    public static float smoothstep(float edge0, float edge1, float x) {
        float t = clamp((x - edge0) / (edge1 - edge0), 0, 1);
        return t * t * (3 - 2 * t );
    }

ふむ。よくわからない。

いろいろぐぐった結果、グラフをみつけて納得。

15
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
18