calculating the distance

Posted By: AttosRH

calculating the distance - 06/10/09 18:16

how do I calculate the distance between 2 models?

c_trace?
c_scan?

thanks in advance
Posted By: Joozey

Re: calculating the distance - 06/10/09 18:26

vec_dist( my.x, you.x )
Posted By: Damocles_

Re: calculating the distance - 06/10/09 18:32

alternatively you can use the Pythagoras
(in case you handle your vectors seperated as variables, and
want do a "selfmade" calculation)

a*a+b*b=c*c

or:

c=sqrt(a*a+b*b)
Posted By: AttosRH

Re: calculating the distance - 06/10/09 18:37

Originally Posted By: Damocles_

a*a+b*b=c*c

or:

c=sqrt(a*a+b*b)


O.o
Posted By: Joozey

Re: calculating the distance - 06/10/09 18:39

Where a = my.x - you.x and b = my.y - you.y.
c is the distance
Posted By: Damocles_

Re: calculating the distance - 06/10/09 18:43

Yes, forgot to add that.
Its just the classic way to calculate distances in
geometry. (a and b beeing the "x" and "y" distances between
the objects positions)

-> its more useful when you dont want the (z) hight of the objects
to influence the distance.
Posted By: WretchedSid

Re: calculating the distance - 06/10/09 18:46

You can also use (a*a)+(b*b)+(c*c) = d (d is the distance², a-c = x-z). I assume that you are using a 3D Space...
© 2024 lite-C Forums