Added angleDiff() function to vector to get the difference in angle from one vector to another.
This commit is contained in:
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user