Convert calculated-2D coordinate to ellipsoid

Hello. I have the sandbox here.

What I’m trying to do is to set a point on the map as the center of a circle. Then, on mousemove, find the angle of the mouse relative to the center point using the north position as the reference, then draw another point on the outer edge of the circle based on the angle (the green dot).

However, with the current calculation, the position of the green dot on the map is not being placed correctly on the circle. In fact it’s rather drawing an ellipsoid circle as the mouse moves. The goal is to actually place the green dot on the outer edge of the circle itself, demonstrated by the red dot.

Peek 2021-05-23 18-39

However, If I moved the center of the circle to somewhere around the equator, the green dot is being placed just fine on the outer edge of the circle. This led me to believe that it has something to do with the globe’s ellipsoid.

Peek 2021-05-23 18-41

There is definitely something wrong with the calculation. I’ve tried many functions to project the coordinates based on the ellipsoid but nothing turned out right. If anyone could give me pointers as to how this should be done, I would be really grateful. Thank you.

  1. Haversine formula
  2. EllipsoidGeodesic, SurfaceDistance

Thank you for the pointers! I will try to implement them

@kasatik143

Thank you for the suggestions! I think you are leading @iwakuya in the correct direction

-Sam