mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
fix for small values in PVector
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user