c++ - Is point A nearby point B in 3D - distance check -
I'm looking for a skilled algorithm to check whether I have a point in 3D or not.
Sqrt ((x2-x1) ^ 2 + (y2-y1) ^ 2 + (z2-z1) ^ 2) & lt; Radius
It does not look very fast and in fact I do not need such a big accuracy. How can I do this?
drop the distance to the square, and sqrt ()
, it Very fast:
((x2-x1) ^ 2 + (y2-y1) ^ 2 + (z2-z1) ^ 2 & ray; radius * radius
Of course, in most cases at least radius * radius
can be calculated prematurely and such as square radius
is stored.
Comments
Post a Comment