-
Notifications
You must be signed in to change notification settings - Fork 7
Lerp
Swifter edited this page Oct 19, 2024
·
2 revisions
Lerp (or linear interpolation) is a mathematical concept which can be used to blend between 2 values.
It is defined as lerp(a, b, t) = (b - a) * t + a where:
-
ais the start point. -
bis the end point. -
tis the position betweenaandb.
When t is:
- 0, the output will be
a - 1, the output will be
b - somewhere in between, it will be a mix of
aandb.

Here's a demonstration of various values of a, b, and t:
lerp(2, 4, 0) = 2
lerp(2, 4, 0.5) = 3 (halfway between 2 and 4)
lerp(2, 4, 1) = 4
-
rm.lerpwill take in numbersa,b, andtand returnlerp(a,b,t).
rm.lerp(2, 4, 0) // 2
rm.lerp(2, 4, 0.5) // 3
rm.lerp(2, 4, 1) // 4-
rm.inverseLerpwill take in numbersa,b, andx(lerp(a,b,t)) and findt.
You can imagine it as doing the reverse operation of lerp, where it finds the t value that generates the number you pass in.
rm.lerp(2, 4, 2) // 0
rm.lerp(2, 4, 3) // 0.5
rm.lerp(2, 4, 4) // 1-
rm.remapwill take in a position in the range ofa1tob1and convert it to a range froma2tob2.
The parameters are ordered like: (x, a1, b1, a2, b2).
rm.remap(2, 2, 4, 1, 2) // 1
rm.remap(3, 2, 4, 1, 2) // 1.5
rm.remap(4, 2, 4, 1, 2) // 2-
rm.slerp1Dworks likerm.lerpbut assumes that values above 1 wrap around to 0. That is to say, it interpolates spherically.
rm.slerp1D(0.2, 0.8, 0.5) // 0You can imagine these values as angles on a sphere and you're finding an angle in between.

- Info
- Difficulty
- Beatmap Objects
- Gameplay Objects
- Walls
- Basic Notemods
- Note Iterators
- Basic Events
- V3 Events
- Custom Events
- Heck Tracks and Animation
- Easings
- Point Types
- Point Utilities
- Heck Animation Baking
- Heck Animation Settings
Non-Vivify Models
Vivify