static public float angleBetween(PVector v1,PVector v2){
  if (v1.x == 0 && v1.y == 0)   return 0.0f;
  if (v2.x == 0 && v2.y == 0)   return 0.0f;
  double dot=v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
  double v1mag=Math.sqrt(v1.x * v1.x + v1.y * v1.y + v1.z * v1.z);
  double v2mag=Math.sqrt(v2.x * v2.x + v2.y * v2.y + v2.z * v2.z);
  double amt=dot / (v1mag * v2mag);
  if (amt <= -1) {
    return PConstants.PI;
  }
 else   if (amt >= 1) {
    return 0;
  }
  return (float)Math.acos(amt);
}

static public float angleBetween ( PVector v1 , PVector v2 ) { if ( v1 . x == 0 && v1 . y == 0 ) return 0.0f ; if ( v2 . x == 0 && v2 . y == 0 ) return 0.0f ; double dot = v1 . x * v2 . x + v1 . y * v2 . y + v1 . z * v2 . z ; double v1mag = Math . sqrt ( v1 . x * v1 . x + v1 . y * v1 . y + v1 . z * v1 . z ) ; double v2mag = Math . sqrt ( v2 . x * v2 . x + v2 . y * v2 . y + v2 . z * v2 . z ) ; double amt = dot / ( v1mag * v2mag ) ; if ( amt <= - 1 ) { return PConstants . PI ; } else if ( amt >= 1 ) { return 0 ; } return ( float ) Math . acos ( amt ) ; }
( begin auto - generated from pvector_anglebetween . xml ) calculates and returns the angle ( in radians ) between two vectors . ( end auto - generated )
