# the distance between 2 points in space

This topic is 5148 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().

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 11
• 15
• 21
• 26
• 11