Added angleDiff() function to vector to get the difference in angle from one vector to another.

This commit is contained in:
Quinn
2023-04-06 10:54:53 -05:00
parent 7438d0f64e
commit a06415f371
2 changed files with 19 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
import static java.lang.Math.acos;
import static java.lang.Math.sqrt;
public class Vector {
@@ -65,4 +66,9 @@ public class Vector {
float mag = this.mag();
return new Vector(x / mag, y / mag, z / mag);
}
float angleDiff(Vector other){
float dot = this.dot(other);
return (float)acos(dot / (this.mag() * other.mag()));
}
}