diff --git a/paper-api/src/main/java/org/bukkit/util/Vector.java b/paper-api/src/main/java/org/bukkit/util/Vector.java index 685148ec62..cebd3ccb7f 100644 --- a/paper-api/src/main/java/org/bukkit/util/Vector.java +++ b/paper-api/src/main/java/org/bukkit/util/Vector.java @@ -303,6 +303,25 @@ public class Vector implements Cloneable, ConfigurationSerializable { return this; } + /** + * Calculates the cross product of this vector with another without mutating + * the original. The cross product is defined as: + * + * + * @param o The other vector + * @return a new vector + */ + public Vector getCrossProduct(Vector o) { + double x = this.y * o.z - o.y * this.z; + double y = this.z * o.x - o.z * this.x; + double z = this.x * o.y - o.x * this.y; + return new Vector(x, y, z); + } + /** * Converts this vector to a unit vector (a vector with length of 1). *