Class VectorMath
java.lang.Object
tk.airshipcraft.commonlib.utils.math.VectorMath
Utility class for vector mathematical operations.
Provides methods for vector rotation, randomization, scaling, and more.
- Since:
- 2023-10-11
- Version:
- 1.1.0
- Author:
- eerieXanthic, notzune
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.util.Vector
instabilizeVector
(org.bukkit.util.Vector v, double instability) Adds a random amount to each component of a vector within a specified range.static org.bukkit.util.Vector
normalizeVector
(org.bukkit.util.Vector v) Normalizes a vector to have a length of 1 while maintaining its direction.static org.bukkit.util.Vector
rotateVectorCC
(org.bukkit.util.Vector vec, org.bukkit.util.Vector axis, double theta) Rotates a vector counterclockwise around a specified axis by a specified angle.static org.bukkit.util.Vector
scaleVector
(org.bukkit.util.Vector v, double factor) Scales a vector by a specified factor.
-
Constructor Details
-
VectorMath
public VectorMath()
-
-
Method Details
-
rotateVectorCC
public static org.bukkit.util.Vector rotateVectorCC(org.bukkit.util.Vector vec, org.bukkit.util.Vector axis, double theta) Rotates a vector counterclockwise around a specified axis by a specified angle.- Parameters:
vec
- The vector to rotate. Must not be null.axis
- The axis of rotation. Must not be null.theta
- The angle of rotation in radians.- Returns:
- The rotated vector.
- Throws:
IllegalArgumentException
- if vec or axis is null.
-
instabilizeVector
public static org.bukkit.util.Vector instabilizeVector(org.bukkit.util.Vector v, double instability) Adds a random amount to each component of a vector within a specified range.- Parameters:
v
- The vector to randomize. Must not be null.instability
- The maximum amount of randomization.- Returns:
- The randomized vector.
- Throws:
IllegalArgumentException
- if v is null.
-
scaleVector
public static org.bukkit.util.Vector scaleVector(org.bukkit.util.Vector v, double factor) Scales a vector by a specified factor.- Parameters:
v
- The vector to scale.factor
- The scaling factor.- Returns:
- The scaled vector.
-
normalizeVector
public static org.bukkit.util.Vector normalizeVector(org.bukkit.util.Vector v) Normalizes a vector to have a length of 1 while maintaining its direction.- Parameters:
v
- The vector to normalize.- Returns:
- The normalized vector.
-