// Calculates the angle between two vectors. // Returns: The angle between the two given vectors. public static float getAngleBetween(CVector aVector1, CVector aVector2) { if (!aVector1.isNormalized()) { aVector1.clone().normalize(); } if (!aVector2.isNormalized()) { aVector2.clone().normalize(); } return(Mathf.Acos(aVector1.dotProd(aVector2))); }
// Determines if a given vector is to the right or left of this vector. // Returns: -1 if to the left. +1 if to the right. public float sign(CVector aVector) { CVector p = getPerpendicularVector(); return(p.dotProd(aVector) < 0 ? -1 : 1); }