Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GoodBoyNinja/4d4d22924cff90b055d212820000216f to your computer and use it in GitHub Desktop.
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.
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