public final class VecHelper
extends java.lang.Object
Vec objects.Vec| Modifier and Type | Method and Description |
|---|---|
static <D extends OneMin> |
add(Vec<D> v1,
Vec<D> v2)
Adds two vectors together.
|
static <D extends OneMin> |
addOptional(Vec<D> v1,
Vec<D> v2)
Adds two vectors together.
|
static <D extends OneMin> |
calculateAngleBetween(Vec<D> v1,
Vec<D> v2)
Calculates the angle between two vectors.
|
static double |
calculateLength(Vec<?> v)
Calculates the length of a vector.
|
static <D extends OneMin> |
calculateVectorComponent(Vec<D> v,
Vec<D> direc)
Calculates the vector projection of
v on direc, which is an orthogonal projection
of v onto a straight line parallel to direc. |
static Vec<Three> |
cross(Vec<Three> v1,
Vec<Three> v2)
Calculates the cross product of two vectors.
|
static java.util.Optional<Vec<Three>> |
crossOptional(Vec<Three> v1,
Vec<Three> v2)
Calculates the cross product of two vectors.
|
static <D extends OneMin> |
divide(Vec<D> v,
double s)
Divides the vector by a scalar.
|
static <D extends OneMin> |
divideOptional(Vec<D> v,
double s)
Divides the vector by a scalar.
|
static <D extends OneMin> |
dot(Vec<D> v1,
Vec<D> v2)
Calculates the dot product of two vectors.
|
static <D extends OneMin> |
dotOptional(Vec<D> v1,
Vec<D> v2)
Calculates the dot product of two vectors.
|
static <D extends OneMin> |
multiply(Vec<D> v,
double s)
Multiplies the vector with a scalar.
|
static <R extends OneMin,C extends OneMin> |
multiply(Vec<R> v,
Mat<R,C> m)
Multiplies a vector with a matrix.
|
static <D extends OneMin> |
multiplyOptional(Vec<D> v,
double s)
Multiplies the vector with a scalar.
|
static <R extends OneMin,C extends OneMin> |
multiplyOptional(Vec<R> v,
Mat<R,C> m)
Multiplies a vector with a matrix.
|
static <D extends OneMin> |
negate(Vec<D> v)
Negates the vector.
|
static <D extends OneMin> |
normalize(Vec<D> v)
Normalizes the vector.
|
static <D extends OneMin> |
subtract(Vec<D> v1,
Vec<D> v2)
Subtracts a vector from another vector.
|
static <D extends OneMin> |
subtractOptional(Vec<D> v1,
Vec<D> v2)
Subtracts a vector from another vector.
|
public static <D extends OneMin> Vec<D> add(Vec<D> v1, Vec<D> v2)
v1 - the first vectorv2 - the second vectorv1 + v2.java.lang.NullPointerException - if v1 or v2 is nulljava.lang.IllegalArgumentException - if the resulting vector lies outside of the vector spacepublic static <D extends OneMin> java.util.Optional<Vec<D>> addOptional(Vec<D> v1, Vec<D> v2)
v1 - the first vectorv2 - the second vectorv1 + v2.
If the resulting vector lies outside of the vector space, an empty Optional will be returned.java.lang.NullPointerException - if v1 or v2 is nullpublic static <D extends OneMin> Vec<D> subtract(Vec<D> v1, Vec<D> v2)
v1 - the first vectorv2 - the second vectorv1 - v2.java.lang.NullPointerException - if v1 or v2 is nulljava.lang.IllegalArgumentException - if the resulting vector lies outside of the vector spacepublic static <D extends OneMin> java.util.Optional<Vec<D>> subtractOptional(Vec<D> v1, Vec<D> v2)
v1 - the first vectorv2 - the second vectorv1 - v2.
If the resulting vector lies outside of the vector space, an empty Optional will be returned.java.lang.NullPointerException - if v1 or v2 is nullpublic static <D extends OneMin> Vec<D> multiply(Vec<D> v, double s)
v - the vectors - the scalarv * sjava.lang.NullPointerException - if v1 or v2 is nulljava.lang.IllegalArgumentException - if the resulting vector lies outside of the vector spacepublic static <D extends OneMin> java.util.Optional<Vec<D>> multiplyOptional(Vec<D> v, double s)
v - the vectors - the scalarv * s.
If the resulting vector lies outside of the vector space, an empty Optional will be returned.java.lang.NullPointerException - if v is nulljava.lang.IllegalArgumentException - if s is equal to (+/-)Infinity or NaNpublic static <R extends OneMin,C extends OneMin> Vec<C> multiply(Vec<R> v, Mat<R,C> m)
m - the matrixv - the vectorv * mjava.lang.NullPointerException - if v1 or v2 is nulljava.lang.IllegalArgumentException - if the resulting vector lies outside of the vector spacepublic static <R extends OneMin,C extends OneMin> java.util.Optional<Vec<C>> multiplyOptional(Vec<R> v, Mat<R,C> m)
m - the matrixv - the vectorv * m.
If the resulting vector lies outside of the vector space, an empty Optional will be returned.java.lang.NullPointerException - if m or v is nullpublic static <D extends OneMin> Vec<D> divide(Vec<D> v, double s)
v - the vectors - the scalarv / sjava.lang.NullPointerException - if v1 or v2 is nulljava.lang.IllegalArgumentException - if the resulting vector lies outside of the vector spacepublic static <D extends OneMin> java.util.Optional<Vec<D>> divideOptional(Vec<D> v, double s)
v - the vectors - the scalarv / s.
If the resulting vector lies outside of the vector space, an empty Optional will be returned.java.lang.NullPointerException - if v is nulljava.lang.IllegalArgumentException - if s is equal to (+/-)Infinity or NaNpublic static Vec<Three> cross(Vec<Three> v1, Vec<Three> v2)
v1 - the first vectorv2 - the second vectorv1 x v2java.lang.NullPointerException - if v1 or v2 is nulljava.lang.IllegalArgumentException - if the resulting vector lies outside of the vector spacepublic static java.util.Optional<Vec<Three>> crossOptional(Vec<Three> v1, Vec<Three> v2)
v1 - the first vectorv2 - the second vectorv1 x v2-
If the resulting vector lies outside of the vector space, an empty Optional will be returned.java.lang.NullPointerException - if v1 or v2 is nullpublic static <D extends OneMin> double dot(Vec<D> v1, Vec<D> v2)
v1 - the first vectorv2 - the second vectorv1 · v2java.lang.NullPointerException - if v1 or v2 is nulljava.lang.IllegalArgumentException - if the dot product is infinitepublic static <D extends OneMin> java.util.Optional<java.lang.Double> dotOptional(Vec<D> v1, Vec<D> v2)
v1 - the first vectorv2 - the second vectorv1 · v2.
If the dot product is infinite, an empty Optional will be returned.java.lang.NullPointerException - if v1 or v2 is nullpublic static <D extends OneMin> Vec<D> negate(Vec<D> v)
v - the vector-vjava.lang.NullPointerException - if v is nullpublic static double calculateLength(Vec<?> v)
v - the vectorv|java.lang.NullPointerException - if v is nullpublic static <D extends OneMin> double calculateAngleBetween(Vec<D> v1, Vec<D> v2)
v1 - the first vectorv2 - the second vectorjava.lang.NullPointerException - if v1 or v2 is nulljava.lang.IllegalArgumentException - if v1 or v2 is a zero vectorpublic static <D extends OneMin> Vec<D> normalize(Vec<D> v)
v - the vectorv / |v|java.lang.NullPointerException - if v is nulljava.lang.IllegalArgumentException - if v is a zero vectorpublic static <D extends OneMin> Vec<D> calculateVectorComponent(Vec<D> v, Vec<D> direc)
v on direc, which is an orthogonal projection
of v onto a straight line parallel to direc.v - the vector which should be projecteddirec - the direction of which the component should be calculatedv on direc.java.lang.NullPointerException - if v or direc is nulljava.lang.IllegalArgumentException - if v is a zero vector