Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula to find distance between 2 3-D points

Status
Not open for further replies.

TheInsider

Programmer
Jul 17, 2000
796
CA
Hi,
Can someone give me a formula to find the distance between any two given 3-D points (x1, y1, z1) and (x2, y2, z2).
Thanks,

Rob Marriott
rob@career-connections.net
 
Thankyou all for looking at my thread but I think I found the solution already.

Rob Marriott
rob@career-connections.net
 
You have to use the Pythagorean Theorem to get the distance between two 2D/3D points.

hypotenuse² = adjacent² + opposite²
(a)² = (b)² + (c)²

2D case:(a = sqrt(b² + c²))
========
dist2D = sqrt((x1 - x2)² + (y1 - y2)²)


3D case: (just add (z1 - z2)²)
========
dist3D = sqrt((x1 - x2)² + (y1 - y2)² + (z1 - z2)²)


Easy, really??
Well, I hope it helps you

Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top