vmorel
vmorel

Reputation: 25

Formula to determine whether a radius is within another radius

I want to define an operation to computer whether a radius is within another one.
My radiuses are defined by tuples (latitude, longitude, radius), with a radius in meters.
In other words, I want to be able to check whether a circle is within another circle, with an application to GPS coordinates.
I need an algorithm in pseudo-code that could be reused in many cases.

The closest formula I've found is the https://en.wikipedia.org/wiki/Haversine_formula

Upvotes: 0

Views: 184

Answers (1)

MBo
MBo

Reputation: 80187

Let circle radii are R and r.
Calculate distance d between circle centers using haversine formula.
Compare d with radii:

d > R + r:  circles don't intersect
Abs(R-r) <= d <= R + r: circles do intersect
Abs(R-r) > d : one circle lies inside another

Upvotes: 1

Related Questions