Distance Between 2 Positions in 3D Space
The ability to find the distance between 2 points in 3D space is a really important function I need to use time and again. I found this website that is really helpful with clear explanations on the use of the formula. http://darkvertex.com/wp/2010/06/05/python-distance-between-2-vectors/ From the webpage I learnt the formula for the distance d between points A (expressed as Ax, Ay, Az) and B (expressed as Bx, By, Bz), would be expressed as such: d = √ Ax-Bx 2 + Ay-By 2 + Az-Bz 2 I was going to use the distance function on an expression in Maya, so I had to write it with MEL commands: vector $a = `xform -q -ws -a -rp "objA"`; vector $b = `xform -q -ws -a -rp "objB"`; // doing the additions and squaring first $myDist = `pow ($a.x-$b.x) 2` + `pow ($a.y-$b.y) 2` + `pow ($a.z-$b.z) 2`; // applying the square root $myDist = `sqrt $myDist`; I hope you it helps if you are looking for the same information. Additional notes: I am w...