Created
February 1, 2021 13:27
-
-
Save GoodBoyNinja/4d4d22924cff90b055d212820000216f to your computer and use it in GitHub Desktop.
This function takes simple circle properties like the radius and degrees, and returns a point on a circle, around the original value. Using this as a position expressions, then calling the function like in the example below, will result in a circular motion that's easily customizable.
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
function CircularMotion (theRadius, degrees, angleShift){ | |
degrees = (degrees === undefined) ? - 90 : -degrees + 90 | |
angleShift = (angleShift === undefined) ? 0 : -angleShift; | |
theRadius = (theRadius === undefined) ? 100 : theRadius; | |
xDir = Math.sin(degreesToRadians(degrees + angleShift)); | |
yDir = Math.cos(degreesToRadians(degrees + angleShift)); | |
return [xDir * theRadius, yDir * theRadius] + value; | |
} | |
CircularMotion (100, time * 90, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment