-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connectors don't crash the game anymore + bump version
- Loading branch information
Showing
3 changed files
with
13 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 8 additions & 7 deletions
15
common/src/main/kotlin/org/valkyrienskies/tournament/util/math/Lerp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
package org.valkyrienskies.tournament.util.math | ||
|
||
fun lerp(a: Double, b: Double, t: Double): Double = | ||
a + (b - a) * t | ||
import kotlin.math.max | ||
import kotlin.math.min | ||
|
||
fun clamp(v: Double, minv: Double, maxv: Double): Double = | ||
if (minv > maxv) clamp(v, maxv, minv) | ||
else min(max(v, minv), maxv) | ||
|
||
fun lerp(a: Float, b: Float, t: Float): Float = | ||
a + (b - a) * t | ||
fun lerp(a: Double, b: Double, t: Double): Double = | ||
clamp(a + (b - a) * t, a, b) | ||
|
||
fun invLerp(a: Double, b: Double, v: Double): Double = | ||
(v - a) / (b - a) | ||
|
||
fun invLerp(a: Float, b: Float, v: Float): Float = | ||
(v - a) / (b - a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters