Merge pull request #2046 from boubpopsyteam/patch-5

Update PVector.java
This commit is contained in:
Daniel Shiffman
2013-08-29 09:27:54 -07:00

View File

@@ -926,9 +926,9 @@ public class PVector implements Serializable {
static public float angleBetween(PVector v1, PVector v2) {
// We get NaN if we pass in a zero vector which can cause problems
// Zero seems like a reasonable angle between a (0,0) vector and something else
if (v1.x == 0 && v1.y == 0) return 0.0f;
if (v2.x == 0 && v2.y == 0) return 0.0f;
// Zero seems like a reasonable angle between a (0,0,0) vector and something else
if (v1.x == 0 && v1.y == 0 && v1.z == 0 ) return 0.0f;
if (v2.x == 0 && v2.y == 0 && v2.z == 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);
@@ -994,4 +994,4 @@ public class PVector implements Serializable {
result = 31 * result + Float.floatToIntBits(z);
return result;
}
}
}