www.jpct.net
jPCT - a 3d engine for Java => Support => Topic started by: bigfishcatcher on September 05, 2008, 01:57:23 am
-
Is there a way to get a float value to represents the distance between SimpleVectors
Thanks
-
A method like this should work:
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) );
}
-
Thanks, that really makes my life easier.
-
No problem ;D
-
Another way to do it:
s1.calcSub(s2).length();
Maybe i should add that method to SimpleVector...
-
While you're at it, why not a calculateAngle(SimpleVector origin, SimpleVector p1, SimpleVector p2)?