diff --git a/core/src/processing/core/PVector.java b/core/src/processing/core/PVector.java index 5f9be436e..78209bb60 100644 --- a/core/src/processing/core/PVector.java +++ b/core/src/processing/core/PVector.java @@ -529,9 +529,10 @@ public class PVector { * @return the angle between the vectors */ static public float angleBetween(PVector v1, PVector v2) { - float dot = v1.dot(v2); - float theta = (float) Math.acos(dot / (v1.mag() * v2.mag())); - return theta; + 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); + return (float) Math.acos(dot / (v1mag * v2mag)); }