View Full Version : distance between 2 point
gibby
04-16-2008, 05:33 PM
newbie here with a newbie question.
How can I determine the distance between two points?
Hope this is correct :)
Create two Nulls (null, null1) and run this jscript:
selectobj("null");
x1=selection(0).kinematics.global.Parameters("posx").value
y1=selection(0).kinematics.global.Parameters("posy").value
z1=selection(0).kinematics.global.Parameters("posz").value
selectobj("null1");
x2=selection(0).kinematics.global.Parameters("posx").value
y2=selection(0).kinematics.global.Parameters("posy").value
z2=selection(0).kinematics.global.Parameters("posz").value
dx=x1-x2
dy=y1-y2
dz=z1-z2
logmessage(Math.sqrt(dx*dx + dy*dy + dz*dz))
Draw linear curve from 2 points (+ Snap on target components)
Press Shift+Enter (Info Selection) > Length
gibby
04-17-2008, 12:12 PM
Draw linear curve from 2 points (+ Snap on target components)
Press Shift+Enter (Info Selection) > Length
Thanks uno. Is there anyway that can be broken down into x, y, and z components?
gibby
04-17-2008, 12:16 PM
Hope this is correct :)
Create two Nulls (null, null1) and run this jscript:
selectobj("null");
x1=selection(0).kinematics.global.Parameters("posx").value
y1=selection(0).kinematics.global.Parameters("posy").value
z1=selection(0).kinematics.global.Parameters("posz").value
selectobj("null1");
x2=selection(0).kinematics.global.Parameters("posx").value
y2=selection(0).kinematics.global.Parameters("posy").value
z2=selection(0).kinematics.global.Parameters("posz").value
dx=x1-x2
dy=y1-y2
dz=z1-z2
logmessage(Math.sqrt(dx*dx + dy*dy + dz*dz))
Thanks miga,
I'm sure this works, but as I said, I'm a newbie and this seems several levels above me :confused:
How do you create a null? What is a null?
And once I get nulls, how do I run scripts?
Sorry for the drawn out questions.
Would be under:
Get - Primitive - Null
Then you open the script window (the paper roll symbol in the bottom left next to "playback"), right click in the bottom white window and check if it's switched to JScript. Then you copy and paste the script into it and click "run" (symbol next to the ?)
gibby
04-17-2008, 01:34 PM
Thanks miga,
I got it working and I even added my own code for getting the x, y, and z components:
logmessage("x=" + dx)
logmessage("y=" + dy)
logmessage("z=" + dz)
logmessage(Math.sqrt(dx*dx + dy*dy + dz*dz))
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.