Skip to content

Commit

Permalink
feat: Clamped Inverse Linear Interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepalesque committed Dec 22, 2024
1 parent 6f10818 commit cf43b68
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ org.gradle.debug=false


# Version
mod_version=1.1.03
mod_version=1.1.04

# Mod
mod_id=zenith
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/net/zepalesque/zenith/util/MathUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,20 @@ public static float nextFloat(float min, float max, RandomSource random) {
return min + (random.nextFloat() * (max - min));
}

public static double clampedInverp(double start, double end, double delta) {
if (delta < start) {
return 0.0;
} else {
return delta > end ? 1.0 : Mth.inverseLerp(delta, start, end);
}
}

public static float clampedInverp(float start, float end, float delta) {
if (delta < start) {
return 0.0F;
} else {
return delta > end ? 1.0F : Mth.inverseLerp(delta, start, end);
}
}

}

0 comments on commit cf43b68

Please sign in to comment.