Created
October 12, 2019 19:32
-
-
Save EIREXE/f5de8336fb4eaa9534b7d388b76a67a6 to your computer and use it in GitHub Desktop.
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
# Interpolates from a to b along a sine wave | |
func sin_pos_interp(from: Vector2, to: Vector2, amplitude: float, frequency: float, value: float) -> Vector2: | |
var dist = (from - to).length() | |
value = clamp(value, 0, 1) | |
if dist != 0: | |
var t = value * dist | |
var x = t | |
var angle = from.angle_to_point(to) | |
var y = amplitude * sin((t/dist)*PI*frequency) | |
var xp = (x * cos(angle)) - (y * sin(angle)) | |
var yp = (x * sin(angle)) + (y * cos(angle)) | |
return from-Vector2(xp, yp) | |
else: | |
return to |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment