Skip to content

Commit

Permalink
add "lorp" (log interpolation) function
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaTheFoxgirl committed Jul 17, 2024
1 parent 1ff3407 commit 64c502f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion inmath/interpolate.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module inmath.interpolate;
private {
import inmath.linalg : Vector, dot, vec2, vec3, vec4, quat;
import inmath.util : isVector, isQuaternion;
import inmath.math : almostEqual, acos, sin, sqrt, clamp, PI;
import inmath.math : almostEqual, acos, sin, sqrt, clamp, PI, exp, log;
import std.conv : to;
}

Expand All @@ -20,6 +20,12 @@ T lerp(T)(T a, T b, float t) {
return a * (1 - t) + b * t;
}

/// Logarithmically interpolates between `a` and `b`, using scalar `t` from 0..1
/// Also known as eerp
T lorp(T)(T a, T b, float t) {
return a * exp( t * log(b / a));
}

/// Linearly interpolates between to vectors or quaternions.
T slerp(T)(T a, T b, float t) if(isVector!T || isQuaternion!T) {
static if(isVector!T) {
Expand Down

0 comments on commit 64c502f

Please sign in to comment.