Reputation: 331
I'm working with Latitude/Longitude Coordinates and i'm trying to find an equation for a circle on the surface that includes all points that have a certain distance(on the surface) from the center.
It's important that this should work also with very big distances (for example half the perimeter of the earth), so the flat-earth approximation probably won't work, but assuming it's a perfect sphere is okay.
Can anybody help?
Thanks in advance!
Upvotes: 0
Views: 443
Reputation: 3132
I have this very same problem.
What I do is to convert the latitude and longitude to Cartesian coordinates fixed at the center of the Earth (which I assume is spherical).
I interpret these coordinates as a mathematical vector.
I also convert the desired "distance from center of circle"
to an angle at the center of the Earth,
that is, if the distance is d
then the angle is alpha = d/R
where R
is the Earth's radius.
I then find three vectors.
The first vector, v1
, is just cos(alpha)
times my original vector,
that is, it points from the center of the Earth to the center of my circle
and it has length R*cos(alpha)
.
The other two vectors, v2
and v3
, have length R*sin(alpha)
,
and they are both perpendicular to v1
and to each other.
I can then get any point on the desired circle by taking
v1 + cos(beta)*v2 + sin(beta)*v3
where beta
can range from 0 to 2*pi.
Finally, if I want the latitude and longitude of that point,
I convert it back from Cartesian coordinates.
If you never actually care about the Cartesian coordinate model but will
instead use only the latitudes and longitudes that result,
you can simplify the procedure slightly by assuming R == 1
.
You can then simplify the formulas so that you never have to define
the variable R
.
The coordinate conversions in either direction can be fairly straightforward.
An easy way to find vector v2
is to take the x and y coordinates of v1
(ignoring z), rotate the resulting vector 90 degrees in the x-y plane
(so if you started with (x,y,z), the new vector is (-y,x,0)),
and then scale the vector to the desired size.
Of course if the x and y coordinates of v1
are zero then you can
let v2
be any vector in the x-y plane.
To get v3
you can take the cross product of v1
and v2
and scale
as desired.
Upvotes: 1