Suppose I have a vector of points as polar coordinates.
Suppose one of those points acts as a probe for which I want to find all the other points within a certain distance.
Is there an algorithm to do this without converting them to Cartesian form?
You are looking for the distance for polar coordinates. You can find the formula in this link.
The distance between points (r1, a1) and (r2, a2) is:
D = sqrt(r1*r1 + r2*r2 - 2*r1*r2*cos(a1-a2))
Be careful, if you plan to scale up your algorithm to many points, probing for points nearby is better done using a spatial index. I'm not aware of the existence of spatial indexes using polar coordinates, and I'm sure they would be a bit complex to implement/use. So if you have:
ask yourself the question whether you should use Cartesian coordinates and a spatial index.
Do the math yourself according to your typical use case:
Using cartesian alongside polar coordinates:
Using polar coordinates only:
Be aware that trigs are bloody expensive in computation time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With