r/askmath•
Sabe

Walking on a circumference

Hey there,

I have a position X,Y which is on the circumference of a circle. I also have the X,Y position of the circle's center.

Given that I want to walk a Z distance on the circle, how do I find out the new X,Y coordinates?

thanks!

Posted Jun 1, 2017, 9:11 PM UTC

44
SabeOP•

I literally just got it. Fuck that was painful, I suck at math.

const rad = atan2(initialPositionY - circleY, initialPositionX - circleX);
const angularSpeed = linearDistanceToTravel / radius;
const x = circleX + Math.cos(rad + angularSpeed) * radius;
const y = circleY + Math.sin(rad + angularSpeed) * radius;
3
Varboa•

First off, is Z a distance along the circumference? If that's the case, all points will be defined by the equation x^2 + y^2 = r^2 if you want to move with respect to straight up/down, and left/right movement, you will need to use that equation, but if you want to talk about rotation, then you would want to use the identity x = r cos(theta) y = r sin(theta). With tan^-1 (y/x) = (theta), r = sqrt(x^2 + y^2 ).

Walking around the edge of the circle would be a change of theta while radius stays the same. So we plug in our x and y values into our respective equations to find theta and r. Then add a (delta theta). Then we will have a new value for theta. Plug back into our equations which output x and y. That will be your new coordinates.

2
ProfessorHoneycomb•

Going into trying to help you I thought this would be pretty easy, and unless I took a really bad rout to trying to figure it out I think this is far from pretty easy. I'm interested to see the answer if someone in this subreddit comes up with it.

1
SabeOP•

ProfessorHoneycomb thanks for taking the time!

1