Skip to content

Instantly share code, notes, and snippets.

@magician11
Created May 21, 2020 07:05
Show Gist options
  • Save magician11/5d88247394e98e06fc256de6526cfa1f to your computer and use it in GitHub Desktop.
Save magician11/5d88247394e98e06fc256de6526cfa1f to your computer and use it in GitHub Desktop.
How to calculate a coordinate on a circle
const degreesToRadians = degrees => (degrees * Math.PI) / 180;
const pointOnCircle = (radius, radians, origin) => {
const x = origin.x + Math.cos(radians) * radius;
const y = origin.y + Math.sin(radians) * radius;
return { x, y };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment