[orx-noise] Add Vector2/3/4 simplex short-hands
This commit is contained in:
@@ -61,4 +61,7 @@ fun simplex(seed: Int, x: Double, y: Double): Double {
|
||||
}
|
||||
|
||||
return 50.0 * (n0 + n1 + n2)
|
||||
}
|
||||
}
|
||||
|
||||
fun Vector2.Companion.simplex(seed: Int, x: Double): Vector2 = Vector2(simplex(seed, x, 0.0, 0.0, 0.0),
|
||||
simplex(seed, 0.0, x + 31.3383, 0.0, 0.0))
|
||||
@@ -99,4 +99,8 @@ fun simplex(seed: Int, x: Double, y: Double, z: Double): Double {
|
||||
}
|
||||
}
|
||||
return 32 * (n0 + n1 + n2 + n3)
|
||||
}
|
||||
}
|
||||
|
||||
fun Vector3.Companion.simplex(seed: Int, x: Double): Vector3 = Vector3(simplex(seed, x, 0.0, 0.0),
|
||||
simplex(seed, 0.0, x + 31.3383, 0.0),
|
||||
simplex(seed, 0.0, 0.0, x - 483.23))
|
||||
@@ -106,3 +106,9 @@ fun simplex(seed: Int, x: Double, y: Double, z: Double, w: Double): Double {
|
||||
|
||||
return 27 * (n0 + n1 + n2 + n3 + n4)
|
||||
}
|
||||
|
||||
fun Vector4.Companion.simplex(seed: Int, x: Double): Vector4 = Vector4(simplex(seed, x, 0.0, 0.0, 0.0),
|
||||
simplex(seed, 0.0, x + 31.3383, 0.0, 0.0),
|
||||
simplex(seed, 0.0, 0.0, x - 483.23, 0.0),
|
||||
simplex(seed, 0.0, 0.0, 0.0, x + 943.3)
|
||||
)
|
||||
@@ -5,4 +5,4 @@ fun valueQuintic(seed: Int, x: Double) = value(seed, x, ::quintic)
|
||||
fun valueHermite(seed: Int, x: Double) = value(seed, x, ::hermite)
|
||||
|
||||
inline fun value(seed: Int, x: Double, crossinline interpolation: (Double) -> Double = ::linear): Double =
|
||||
value(seed, x, 0.0)
|
||||
value(seed, x, 0.0, interpolation)
|
||||
Reference in New Issue
Block a user