distance = sqrt( (x2 - x1)^2 + (y2 - y1)^2 )
That is simple, isn't it?
The problem( for me ), is how to do it when we are using 3-dimensional coordinates?
A(x1, y1, z1) and B(x2, y2, z2) ?
regards
Distance between 2 points in 3D
Hello there!
From the basics, i know, that we can calculate distance between 2 points in 2D using the:
Remember SQRT is an expensive operation.
If you are comparing distances it's quicker to compare the Squared distances.
i.e.
If SQRT((x1-x2)^2+(y1-y2)^2+(z1-z2)^2) > 10 Then
...
becomes
If (x1-x2)^2+(y1-y2)^2+(z1-z2)^2 > 100 Then
I hope this is useful!
If you are comparing distances it's quicker to compare the Squared distances.
i.e.
If SQRT((x1-x2)^2+(y1-y2)^2+(z1-z2)^2) > 10 Then
...
becomes
If (x1-x2)^2+(y1-y2)^2+(z1-z2)^2 > 100 Then
I hope this is useful!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement