### Author Topic: Distance between SimpleVectors  (Read 3280 times)

#### bigfishcatcher

• byte
• • Posts: 17 ##### Distance between SimpleVectors
« on: September 05, 2008, 01:57:23 am »
Is there a way to get a float value to represents the distance between SimpleVectors

Thanks

#### paulscode

• double
•     • • Posts: 863 ##### Re: Distance between SimpleVectors
« Reply #1 on: September 05, 2008, 02:22:44 am »
A method like this should work:

Code: [Select]
`public float distanceBetweenVectors( SimpleVector a, SimpleVector b ){    return (float) Math.sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) + (a.z-b.z)*(a.z-b.z) );}`

#### bigfishcatcher

• byte
• • Posts: 17 ##### Re: Distance between SimpleVectors
« Reply #2 on: September 05, 2008, 02:33:47 am »
Thanks, that really makes my life easier.

#### paulscode

• double
•     • • Posts: 863 ##### Re: Distance between SimpleVectors
« Reply #3 on: September 05, 2008, 03:42:50 am »
No problem #### EgonOlsen

•     • • Posts: 12092 ##### Re: Distance between SimpleVectors
« Reply #4 on: September 05, 2008, 09:24:13 am »
Another way to do it:

Code: [Select]
`s1.calcSub(s2).length();`
Maybe i should add that method to SimpleVector...

#### AGP

•       