View Full Version : Distance between points/nulls  howto
scrolllock 03032006, 12:07 PM Does anyone know how to calculate the distance between two nulls or object origins every one moment? I need to know the distance between two nulls travelling in x,y,z in every frame. Any suggestions with expressions or something else ?


Piddu
03032006, 12:27 PM
Create an expression like this:
sqrt( ([Null (2).Position.X]  [Null (1).Position.X]) * ([Null (2).Position.X]  [Null (1).Position.X]) + ([Null (2).Position.Y]  [Null (1).Position.Y]) * ([Null (2).Position.Y]  [Null (1).Position.Y]) + ([Null (2).Position.Z]  [Null (1).Position.Z]) * ([Null (2).Position.Z]  [Null (1).Position.Z]))
the formula of distance between two points is:
point1 (x1, y1, z1)
point2 (x2, y2, z2)
sqrt ((x1  x2)^2 + (y1  y2)^2 + (z1  z2)^2)
Bye
scrolllock
03032006, 12:47 PM
Nice! Thanks!
btw a colegue of mine said that I need to have absolute values for X, Y, Z for this expression to work. I made it anyway, thanks again.
zuzzabuzz
03032006, 02:25 PM
As much as I hated it in high school, the pythagorean theorom is really a great piece of work and very useful to me in college. Just wanted to give a shout out to Pythagoras. :applause:
Squaring the position components (x^2) will essentialy act as taking the absolute value, so it will work either way.
I just want to say that that was scarily useful...
;)
0
evenflcw
03032006, 07:32 PM
Use the Expression Builder as reference to find out what function you can/need to use. It lists and explains all available functions. If you like wizards, use the BUilder to build the expression. After you're done in the Builder convert to 'lscript notation' (read about 'bracket' and 'lscript notation' in the Expression builder) to make the expression solve interactivly, since 'bracket notation' will usually require you first scrub the timeline to update.
vmag is the function to use to find out the distance between two vectors and wpos is the 'lscript notation' method used for world position.
vmag( null1.wpos(Time)  null2.wpos(Time) )
jeremyhardin
03042006, 01:04 AM
Use the Expression Builder as reference to find out what function you can/need to use. It lists and explains all available functions. If you like wizards, use the BUilder to build the expression. After you're done in the Builder convert to 'lscript notation' (read about 'bracket' and 'lscript notation' in the Expression builder) to make the expression solve interactivly, since 'bracket notation' will usually require you first scrub the timeline to update.
vmag is the function to use to find out the distance between two vectors and wpos is the 'lscript notation' method used for world position.
vmag( null1.wpos(Time)  null2.wpos(Time) )
evenflcw is right. vmag is perfect for this.
What is the formula for creating a circle from any three perimeter points? This would help me out very much.
I used to use the Circle/Sphere plug from Shekinah Studios but couldn't contact them to reconfigue when I changed to a USB dongle. Note that a sphere can be created from any four points on the sphere's surface in 3d space (don't really use that too much).
Thanks in advance.
Riff Masteroff
Piddu
03042006, 10:55 PM
Doh! I forget the vmag function. What an idiot!
Riff, you have to search on google: "circle from three points"
Here is an example result:
http://astronomy.swin.edu.au/~pbourke/geometry/circlefrom3/
Bye
CGTalk Moderation
03042006, 10:55 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©20002015, Jelsoft Enterprises Ltd.