# the distance between 2 points in space

This topic is 4811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

does anyone know a good way to determine the distance between 2 points in space?

##### Share on other sites
This should do it.

HERE

Hope that helps,

ace

##### Share on other sites
thank you. is there a library with a squareroot function built in?

##### Share on other sites
Probably be included by windows.h somewhere along the line, other than that i can't remember, sorry.

ace

##### Share on other sites
I haven't seen a (modern) language without it.

C: sqrt (#include <math.h>)
C++: std::sqrt (#include <cmath>)
Java: Math.sqrt

##### Share on other sites
Hey man! This is the Pythagoras theorem!

However this is the code

A = (x1, y1, z1)
B = (x2, y2, z2)

d = sqrt( (x2-x1)2 + (y2-y1)2 + (z2-z1)2 )

##### Share on other sites
For C++.NET the square root function is Math::Sqrt().

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 14
• 14
• 9
• ### Forum Statistics

• Total Topics
633370
• Total Posts
3011542
• ### Who's Online (See full list)

There are no registered users currently online

×