Package civitas.celestis.math.vector
Class Vectors
java.lang.Object
civitas.celestis.math.vector.Vectors
A static utility class which contains methods related to
vectors.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Vector2Returns the simple average of the provided vectors.static Vector2Returns the simple average of the two vectors.static Vector3Returns the simple average of the provided vectors.static Vector3Returns the simple average of the two vectors.static Vector4Returns the simple average of the provided vectors.static Vector4Returns the simple average of the two vectors.static booleanChecks if the provided valuevalis within the range of[min, max].static booleanChecks if the provided valuevalis within the range of[min, max].static booleanChecks if the provided valuevalis within the range of[min, max].static <V extends Vector<V>>
booleanisInRange(V val, V min, V max) Checks if the provided valuevalis within the range of[min, max].static Vector2Performs linear interpolation (LERP) between the starting valuesand the ending valuee.static Vector3Performs linear interpolation (LERP) between the starting valuesand the ending valuee.static Vector4Performs linear interpolation (LERP) between the starting valuesand the ending valuee.static <V extends Vector<V>>
Vlerp(V s, V e, double t) Performs linear interpolation (LERP) between the starting valuesand the ending valuee.static Vector2Returns the collective maximum vector between the provided vectors.static Vector3Returns the collective maximum vector between the provided vectors.static Vector4Returns the collective maximum vector between the provided vectors.static Vector2Returns the collective minimum vector between the provided vectors.static Vector3Returns the collective minimum vector between the provided vectors.static Vector4Returns the collective minimum vector between the provided vectors.static Vector2random2()Returns a random unit vector.static Vector3random3()Returns a random unit vector.static Vector4random4()Returns a random unit vector.static Vector2Returns the sum of the provided values.static Vector2Returns the sum of the two values.static Vector3Returns the sum of the provided values.static Vector3Returns the sum of the two values.static Vector4Returns the sum of the provided values.static Vector4Returns the sum of the two values.
-
Method Details
-
random2
Returns a random unit vector. (a vector with a Euclidean norm of1)- Returns:
- A random unit vector
-
random3
Returns a random unit vector. (a vector with a Euclidean norm of1)- Returns:
- A random unit vector
-
random4
Returns a random unit vector. (a vector with a Euclidean norm of1)- Returns:
- A random unit vector
-
isInRange
public static <V extends Vector<V>> boolean isInRange(@Nonnull V val, @Nonnull V min, @Nonnull V max) Checks if the provided valuevalis within the range of[min, max].- Type Parameters:
V- The type of vector to use for this operation- Parameters:
val- The value to comparemin- The minimum allowed valuemax- The maximum allowed value- Returns:
trueif the value is within the range of[min, max]
-
isInRange
Checks if the provided valuevalis within the range of[min, max].- Parameters:
val- The value to comparemin- The minimum allowed valuemax- The maximum allowed value- Returns:
trueif the value is within the range of[min, max]
-
isInRange
Checks if the provided valuevalis within the range of[min, max].- Parameters:
val- The value to comparemin- The minimum allowed valuemax- The maximum allowed value- Returns:
trueif the value is within the range of[min, max]
-
isInRange
Checks if the provided valuevalis within the range of[min, max].- Parameters:
val- The value to comparemin- The minimum allowed valuemax- The maximum allowed value- Returns:
trueif the value is within the range of[min, max]
-
sum
Returns the sum of the two values.- Parameters:
v1- The first value to addv2- The second value to add- Returns:
- The sum of the provided values
-
sum
Returns the sum of the provided values.- Parameters:
values- The values to sum- Returns:
- The sum of the provided values
-
sum
Returns the sum of the two values.- Parameters:
v1- The first value to addv2- The second value to add- Returns:
- The sum of the provided values
-
sum
Returns the sum of the provided values.- Parameters:
values- The values to sum- Returns:
- The sum of the provided values
-
sum
Returns the sum of the two values.- Parameters:
v1- The first value to addv2- The second value to add- Returns:
- The sum of the provided values
-
sum
Returns the sum of the provided values.- Parameters:
values- The values to sum- Returns:
- The sum of the provided values
-
avg
Returns the simple average of the two vectors. This is equivalent to the centroid in a geometric context.- Parameters:
v1- The first vector to averagev2- The second vector to average- Returns:
- The simple average of the two vectors
-
avg
Returns the simple average of the provided vectors. This is equivalent to the centroid in a geometric context.- Parameters:
values- The vectors to average- Returns:
- The simple average of the provided vectors
-
avg
Returns the simple average of the two vectors. This is equivalent to the centroid in a geometric context.- Parameters:
v1- The first vector to averagev2- The second vector to average- Returns:
- The simple average of the two vectors
-
avg
Returns the simple average of the provided vectors. This is equivalent to the centroid in a geometric context.- Parameters:
values- The vectors to average- Returns:
- The simple average of the provided vectors
-
avg
Returns the simple average of the two vectors. This is equivalent to the centroid in a geometric context.- Parameters:
v1- The first vector to averagev2- The second vector to average- Returns:
- The simple average of the two vectors
-
avg
Returns the simple average of the provided vectors. This is equivalent to the centroid in a geometric context.- Parameters:
values- The vectors to average- Returns:
- The simple average of the provided vectors
-
lerp
Performs linear interpolation (LERP) between the starting valuesand the ending valuee.- Type Parameters:
V- The type of vector to use for this operation- Parameters:
s- The starting valuee- The ending valuet- The interpolation parameter ([0, 1])- Returns:
- The interpolated value between the starting and ending values
sande - Throws:
IllegalArgumentException- When the starting vector and the ending vector have a different dimension count (arithmetic is impossible)
-
lerp
Performs linear interpolation (LERP) between the starting valuesand the ending valuee.- Parameters:
s- The starting valuee- The ending valuet- The interpolation parameter ([0, 1])- Returns:
- The interpolated value between the starting and ending values
sande
-
lerp
Performs linear interpolation (LERP) between the starting valuesand the ending valuee.- Parameters:
s- The starting valuee- The ending valuet- The interpolation parameter ([0, 1])- Returns:
- The interpolated value between the starting and ending values
sande
-
lerp
Performs linear interpolation (LERP) between the starting valuesand the ending valuee.- Parameters:
s- The starting valuee- The ending valuet- The interpolation parameter ([0, 1])- Returns:
- The interpolated value between the starting and ending values
sande
-
min
Returns the collective minimum vector between the provided vectors.- Parameters:
values- The vectors of which to get the minimum vector of- Returns:
- The minimum vector of the provided vectors
-
min
Returns the collective minimum vector between the provided vectors.- Parameters:
values- The vectors of which to get the minimum vector of- Returns:
- The minimum vector of the provided vectors
-
min
Returns the collective minimum vector between the provided vectors.- Parameters:
values- The vectors of which to get the minimum vector of- Returns:
- The minimum vector of the provided vectors
-
max
Returns the collective maximum vector between the provided vectors.- Parameters:
values- The vectors of which to get the maximum vector of- Returns:
- The maximum vector of the provided vectors
-
max
Returns the collective maximum vector between the provided vectors.- Parameters:
values- The vectors of which to get the maximum vector of- Returns:
- The maximum vector of the provided vectors
-
max
Returns the collective maximum vector between the provided vectors.- Parameters:
values- The vectors of which to get the maximum vector of- Returns:
- The maximum vector of the provided vectors
-