T - A phantom type parameterpublic final class PVectorM2L<T> extends Object implements PVector2LType<T>
A two-dimensional mutable vector type with integer elements.
Values of this type cannot be accessed safely from multiple threads without explicit synchronization.
| Modifier and Type | Class and Description |
|---|---|
static class |
PVectorM2L.ContextPVM2L
Preallocated storage to allow all vector functions to run without
allocating.
|
| Constructor and Description |
|---|
PVectorM2L()
Default constructor, initializing the vector with values
[0, 0,
0]. |
PVectorM2L(long in_x,
long in_y)
Construct a vector initialized with the given values.
|
PVectorM2L(PVectorReadable2LType<T> in_v)
Construct a vector initialized with the values given in the vector
in_v. |
| Modifier and Type | Method and Description |
|---|---|
static <T,V extends PVectorWritable2LType<T>> |
absolute(PVectorReadable2LType<T> v,
V out)
Calculate the absolute values of the elements in vector
v, saving
the result to out. |
static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> |
absoluteInPlace(V v)
Calculate the absolute values of the elements in vector
v, saving
the result to v. |
static <T,V extends PVectorWritable2LType<T>> |
add(PVectorReadable2LType<T> v0,
PVectorReadable2LType<T> v1,
V out)
Calculate the element-wise sum of the vectors
v0 and v1,
saving the result to out. |
static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> |
addInPlace(V v0,
PVectorReadable2LType<T> v1)
Calculate the element-wise sum of the vectors
v0 and v1,
saving the result to v0. |
static <T,V extends PVectorWritable2LType<T>> |
addScaled(PVectorReadable2LType<T> v0,
PVectorReadable2LType<T> v1,
double r,
V out)
Calculate the element-wise sum of the vectors
v0 and the
element-wise product of v1 and r, saving the result to
out. |
static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> |
addScaledInPlace(V v0,
PVectorReadable2LType<T> v1,
double r)
Calculate the element-wise sum of the vectors
v0 and the
element-wise product of v1 and r, saving the result to
v0. |
static <T> double |
angle(PVectorReadable2LType<T> v0,
PVectorReadable2LType<T> v1)
Calculate the angle between vectors
v0 and v1, in radians. |
static <T,V extends PVectorWritable2LType<T>> |
clamp(PVectorReadable2LType<T> v,
long minimum,
long maximum,
V out)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <T,V extends PVectorWritable2LType<T>> |
clampByPVector(PVectorReadable2LType<T> v,
PVectorReadable2LType<T> minimum,
PVectorReadable2LType<T> maximum,
V out)
Clamp the elements of the vector
v to the inclusive range given by
the corresponding elements in minimum and maximum, saving
the result to out. |
static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> |
clampByPVectorInPlace(V v,
PVectorReadable2LType<T> minimum,
PVectorReadable2LType<T> maximum)
Clamp the elements of the vector
v to the inclusive range given by
the corresponding elements in minimum and maximum, saving
the result to v. |
static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> |
clampInPlace(V v,
long minimum,
long maximum)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <T,V extends PVectorWritable2LType<T>> |
clampMaximum(PVectorReadable2LType<T> v,
long maximum,
V out)
Clamp the elements of the vector
v to the range {@code [-Infinity
.. |
static <T,V extends PVectorWritable2LType<T>> |
clampMaximumByPVector(PVectorReadable2LType<T> v,
PVectorReadable2LType<T> maximum,
V out)
Clamp the elements of the vector
v to the inclusive range given by
the corresponding elements in maximum, saving the result to out. |
static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> |
clampMaximumByPVectorInPlace(V v,
PVectorReadable2LType<T> maximum)
Clamp the elements of the vector
v to the inclusive range given by
the corresponding elements in maximum, saving the result to v. |
static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> |
clampMaximumInPlace(V v,
long maximum)
Clamp the elements of the vector
v to the range {@code [-Infinity
.. |
static <T,V extends PVectorWritable2LType<T>> |
clampMinimum(PVectorReadable2LType<T> v,
long minimum,
V out)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <T,V extends PVectorWritable2LType<T>> |
clampMinimumByPVector(PVectorReadable2LType<T> v,
PVectorReadable2LType<T> minimum,
V out)
Clamp the elements of the vector
v to the inclusive range given by
the corresponding elements in minimum, saving the result to out. |
static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> |
clampMinimumByPVectorInPlace(V v,
PVectorReadable2LType<T> minimum)
Clamp the elements of the vector
v to the inclusive range given by
the corresponding elements in minimum, saving the result to v. |
static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> |
clampMinimumInPlace(V v,
long minimum)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <T,U extends PVectorWritable2LType<T>> |
copy(PVectorReadable2LType<T> input,
U output)
Copy all elements of the vector
input to the vector output. |
void |
copyFrom2L(VectorReadable2LType in_v)
Set the current vector to the contents of the input vector.
|
void |
copyFromTyped2L(PVectorReadable2LType<T> in_v)
Set the current vector to the contents of the input vector.
|
static <T> long |
distance(PVectorM2L.ContextPVM2L c,
PVectorReadable2LType<T> v0,
PVectorReadable2LType<T> v1)
Calculate the distance between the two vectors
v0 and v1. |
static <T> long |
dotProduct(PVectorReadable2LType<T> v0,
PVectorReadable2LType<T> v1)
Calculate the scalar product of the vectors
v0 and v1. |
boolean |
equals(Object obj) |
long |
getXL() |
long |
getYL() |
int |
hashCode() |
static <T,V extends PVectorWritable2LType<T>> |
interpolateLinear(PVectorM2L.ContextPVM2L c,
PVectorReadable2LType<T> v0,
PVectorReadable2LType<T> v1,
double alpha,
V r)
Linearly interpolate between
v0 and v1 by the amount alpha, saving the result to r. |
static <T> long |
magnitude(PVectorReadable2LType<T> v)
Calculate the magnitude of the vector
v. |
static <T> long |
magnitudeSquared(PVectorReadable2LType<T> v)
Calculate the squared magnitude of the vector
v. |
static <T,V extends PVectorWritable2LType<T>> |
projection(PVectorReadable2LType<T> p,
PVectorReadable2LType<T> q,
V r)
Calculate the projection of the vector
p onto the vector q,
saving the result in r. |
static <T,V extends PVectorWritable2LType<T>> |
scale(PVectorReadable2LType<T> v,
double r,
V out)
Scale the vector
v by the scalar r, saving the result to
out. |
static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> |
scaleInPlace(V v,
long r)
Scale the vector
v by the scalar r, saving the result to
v. |
void |
set2L(long in_x,
long in_y)
Set the current
x and y values of the current vector. |
void |
setXL(long in_x)
Set the current
x value of the current vector. |
void |
setYL(long in_y)
Set the current
y value of the current vector. |
static <T,V extends PVectorWritable2LType<T>> |
subtract(PVectorReadable2LType<T> v0,
PVectorReadable2LType<T> v1,
V out)
Subtract the vector
v1 from the vector v0, saving the
result to out. |
static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> |
subtractInPlace(V v0,
PVectorReadable2LType<T> v1)
Subtract the vector
v1 from the vector v0, saving the
result to v0. |
String |
toString() |
public PVectorM2L()
[0, 0,
0].public PVectorM2L(long in_x,
long in_y)
in_x - The x valuein_y - The y valuepublic PVectorM2L(PVectorReadable2LType<T> in_v)
in_v.in_v - The source vectorpublic static <T,V extends PVectorWritable2LType<T>> V absolute(PVectorReadable2LType<T> v, V out) throws ArithmeticException
v, saving
the result to out.T - A phantom type parameterV - The precise type of vectorv - The input vectorout - The output vector(abs v.x, abs v.y, abs v.z)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> V absoluteInPlace(V v) throws ArithmeticException
v, saving
the result to v.T - A phantom type parameterV - The precise type of vectorv - The input vector(abs v.x, abs v.y, abs v.z)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable2LType<T>> V add(PVectorReadable2LType<T> v0, PVectorReadable2LType<T> v1, V out) throws ArithmeticException
v0 and v1,
saving the result to out.T - A phantom type parameterV - The precise type of vectorv0 - The left input vectorv1 - The right input vectorout - The output vector(v0.x + v1.x, v0.y + v1.y, v0.z + v1.z)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> V addInPlace(V v0, PVectorReadable2LType<T> v1) throws ArithmeticException
v0 and v1,
saving the result to v0.T - A phantom type parameterV - The precise type of vectorv0 - The left input vectorv1 - The right input vector(v0.x + v1.x, v0.y + v1.y, v0.z + v1.z)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable2LType<T>> V addScaled(PVectorReadable2LType<T> v0, PVectorReadable2LType<T> v1, double r, V out) throws ArithmeticException
v0 and the
element-wise product of v1 and r, saving the result to
out.T - A phantom type parameterV - The precise type of vectorv0 - The left input vectorv1 - The right input vectorout - The output vectorr - The scaling value(v0.x + (v1.x * r), v0.y + (v1.y * r), v0.z + (v1.z * r))ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> V addScaledInPlace(V v0, PVectorReadable2LType<T> v1, double r) throws ArithmeticException
v0 and the
element-wise product of v1 and r, saving the result to
v0.T - A phantom type parameterV - The precise type of vectorv0 - The left input vectorv1 - The right input vectorr - The scaling value(v0.x + (v1.x * r), v0.y + (v1.y * r), v0.z + (v1.z * r))ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T> double angle(PVectorReadable2LType<T> v0, PVectorReadable2LType<T> v1)
v0 and v1, in radians.T - A phantom type parameterv0 - The left input vectorv1 - The right input vectorpublic static <T,V extends PVectorWritable2LType<T>> V clamp(PVectorReadable2LType<T> v, long minimum, long maximum, V out)
v to the range [minimum ..
maximum] inclusive, saving the result to out.T - A phantom type parameterV - The precise type of vectorv - The input vectorminimum - The minimum allowed valuemaximum - The maximum allowed valueout - The output vectormaximum and at
least minimumpublic static <T,V extends PVectorWritable2LType<T>> V clampByPVector(PVectorReadable2LType<T> v, PVectorReadable2LType<T> minimum, PVectorReadable2LType<T> maximum, V out)
v to the inclusive range given by
the corresponding elements in minimum and maximum, saving
the result to out.T - A phantom type parameterV - The precise type of vectorv - The input vectorminimum - The vector containing the minimum acceptable valuesmaximum - The vector containing the maximum acceptable valuesout - The output vector(min(max(v.x, minimum.x), maximum.x), min(max(v.y,
minimum.y), maximum.y), min(max(v.z, minimum.z), maximum.z))public static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> V clampByPVectorInPlace(V v, PVectorReadable2LType<T> minimum, PVectorReadable2LType<T> maximum)
v to the inclusive range given by
the corresponding elements in minimum and maximum, saving
the result to v.T - A phantom type parameterV - The precise type of vectorv - The input vectorminimum - The vector containing the minimum acceptable valuesmaximum - The vector containing the maximum acceptable values(min(max(v.x, minimum.x), maximum.x), min(max(v.y,
minimum.y), maximum.y), min(max(v.z, minimum.z), maximum.z))public static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> V clampInPlace(V v, long minimum, long maximum)
v to the range [minimum ..
maximum] inclusive, saving the result to v.T - A phantom type parameterV - The precise type of vectorv - The input vectorminimum - The minimum allowed valuemaximum - The maximum allowed valuemaximum and at
least minimum, in vpublic static <T,V extends PVectorWritable2LType<T>> V clampMaximum(PVectorReadable2LType<T> v, long maximum, V out)
v to the range [-Infinity
.. maximum] inclusive, saving the result to out.T - A phantom type parameterV - The precise type of vectorv - The input vectorout - The output vectormaximum - The maximum allowed valuemaximumpublic static <T,V extends PVectorWritable2LType<T>> V clampMaximumByPVector(PVectorReadable2LType<T> v, PVectorReadable2LType<T> maximum, V out)
v to the inclusive range given by
the corresponding elements in maximum, saving the result to out.T - A phantom type parameterV - The precise type of vectorv - The input vectormaximum - The vector containing the maximum acceptable valuesout - The output vector(min(v.x, maximum.x), min(v.y, maximum.y), min(v.z,
maximum.z))public static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> V clampMaximumByPVectorInPlace(V v, PVectorReadable2LType<T> maximum)
v to the inclusive range given by
the corresponding elements in maximum, saving the result to v.T - A phantom type parameterV - The precise type of vectorv - The input vectormaximum - The vector containing the maximum acceptable values(min(v.x, maximum.x), min(v.y, maximum.y), min(v.z,
maximum.z))public static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> V clampMaximumInPlace(V v, long maximum)
v to the range [-Infinity
.. maximum] inclusive, saving the result to v.T - A phantom type parameterV - The precise type of vectorv - The input vectormaximum - The maximum allowed valuemaximum , in
vpublic static <T,V extends PVectorWritable2LType<T>> V clampMinimum(PVectorReadable2LType<T> v, long minimum, V out)
v to the range [minimum ..
Infinity] inclusive, saving the result to out.T - A phantom type parameterV - The precise type of vectorv - The input vectorout - The output vectorminimum - The minimum allowed valueminimumpublic static <T,V extends PVectorWritable2LType<T>> V clampMinimumByPVector(PVectorReadable2LType<T> v, PVectorReadable2LType<T> minimum, V out)
v to the inclusive range given by
the corresponding elements in minimum, saving the result to out.T - A phantom type parameterV - The precise type of vectorv - The input vectorout - The output vectorminimum - The vector containing the minimum acceptable values(max(v.x, minimum.x), max(v.y, minimum.y), max(v.z,
minimum.z))public static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> V clampMinimumByPVectorInPlace(V v, PVectorReadable2LType<T> minimum)
v to the inclusive range given by
the corresponding elements in minimum, saving the result to v.T - A phantom type parameterV - The precise type of vectorv - The input vectorminimum - The vector containing the minimum acceptable values(max(v.x, minimum.x), max(v.y, minimum.y), max(v.z,
minimum.z)) , in vpublic static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> V clampMinimumInPlace(V v, long minimum)
v to the range [minimum ..
Infinity] inclusive, saving the result to v.T - A phantom type parameterV - The precise type of vectorv - The input vectorminimum - The minimum allowed valueminimum, in
v.public static <T,U extends PVectorWritable2LType<T>> U copy(PVectorReadable2LType<T> input, U output)
input to the vector output.U - The specific vector typeT - A phantom type parameterinput - The input vectoroutput - The output vectorpublic static <T> long distance(PVectorM2L.ContextPVM2L c, PVectorReadable2LType<T> v0, PVectorReadable2LType<T> v1) throws ArithmeticException
v0 and v1.T - A phantom type parameterc - Preallocated storagev0 - The left input vectorv1 - The right input vectorArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T> long dotProduct(PVectorReadable2LType<T> v0, PVectorReadable2LType<T> v1) throws ArithmeticException
v0 and v1.T - A phantom type parameterv0 - The left input vectorv1 - The right input vectorArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable2LType<T>> V interpolateLinear(PVectorM2L.ContextPVM2L c, PVectorReadable2LType<T> v0, PVectorReadable2LType<T> v1, double alpha, V r)
v0 and v1 by the amount alpha, saving the result to r.
The alpha parameter controls the degree of interpolation, such
that:
interpolateLinear(v0, v1, 0.0, r) -> r = v0interpolateLinear(v0, v1, 1.0, r) -> r = v1T - A phantom type parameterV - The precise type of vectorc - Preallocated storagev0 - The left input vectorv1 - The right input vectoralpha - The interpolation value, between 0.0 and 1.0r - The result vectorrpublic static <T> long magnitude(PVectorReadable2LType<T> v) throws ArithmeticException
v.
Correspondingly, magnitude(normalize(v)) == 1.0.T - A phantom type parameterv - The input vectorArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T> long magnitudeSquared(PVectorReadable2LType<T> v) throws ArithmeticException
v.T - A phantom type parameterv - The input vectorArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable2LType<T>> V projection(PVectorReadable2LType<T> p, PVectorReadable2LType<T> q, V r) throws ArithmeticException
p onto the vector q,
saving the result in r.T - A phantom type parameterV - The precise type of vectorp - The left vectorq - The right vectorr - The output vector((dotProduct p q) / magnitudeSquared q) * qArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable2LType<T>> V scale(PVectorReadable2LType<T> v, double r, V out) throws ArithmeticException
v by the scalar r, saving the result to
out.T - A phantom type parameterV - The precise type of vectorv - The input vectorr - The scaling valueout - The output vector(v.x * r, v.y * r, v.z * r)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> V scaleInPlace(V v, long r) throws ArithmeticException
v by the scalar r, saving the result to
v.T - A phantom type parameterV - The precise type of vectorv - The input vectorr - The scaling value(v.x * r, v.y * r, v.z * r)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable2LType<T>> V subtract(PVectorReadable2LType<T> v0, PVectorReadable2LType<T> v1, V out) throws ArithmeticException
v1 from the vector v0, saving the
result to out.T - A phantom type parameterV - The precise type of vectorv0 - The left input vectorv1 - The right input vectorout - The output vector(v0.x - v1.x, v0.y - v1.y, v0.z - v1.z)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable2LType<T> & PVectorReadable2LType<T>> V subtractInPlace(V v0, PVectorReadable2LType<T> v1) throws ArithmeticException
v1 from the vector v0, saving the
result to v0.T - A phantom type parameterV - The precise type of vectorv0 - The left input vectorv1 - The right input vector(v0.x - v1.x, v0.y - v1.y, v0.z - v1.z)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic void copyFrom2L(VectorReadable2LType in_v)
VectorWritable2LTypecopyFrom2L in interface VectorWritable2LTypein_v - The input vectorpublic void copyFromTyped2L(PVectorReadable2LType<T> in_v)
PVectorWritable2LTypecopyFromTyped2L in interface PVectorWritable2LType<T>in_v - The input vectorpublic long getXL()
getXL in interface VectorReadable2LTypepublic void setXL(long in_x)
VectorWritable2LTypex value of the current vector.setXL in interface VectorWritable2LTypein_x - The new x value.public long getYL()
getYL in interface VectorReadable2LTypepublic void setYL(long in_y)
VectorWritable2LTypey value of the current vector.setYL in interface VectorWritable2LTypein_y - The new y value.public void set2L(long in_x,
long in_y)
VectorWritable2LTypex and y values of the current vector.set2L in interface VectorWritable2LTypein_x - The new x value.in_y - The new y value.Copyright © 2017 <code@io7m.com> http://io7m.com