T - A phantom type parameterpublic final class PVectorM2I<T> extends Object implements PVector2IType<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 |
PVectorM2I.ContextPVM2I
Preallocated storage to allow all vector functions to run without
allocating.
|
| Constructor and Description |
|---|
PVectorM2I()
Default constructor, initializing the vector with values
[0, 0,
0]. |
PVectorM2I(int in_x,
int in_y)
Construct a vector initialized with the given values.
|
PVectorM2I(PVectorReadable2IType<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 PVectorWritable2IType<T>> |
absolute(PVectorReadable2IType<T> v,
V out)
Calculate the absolute values of the elements in vector
v, saving
the result to out. |
static <T,V extends PVectorWritable2IType<T> & PVectorReadable2IType<T>> |
absoluteInPlace(V v)
Calculate the absolute values of the elements in vector
v, saving
the result to v. |
static <T,V extends PVectorWritable2IType<T>> |
add(PVectorReadable2IType<T> v0,
PVectorReadable2IType<T> v1,
V out)
Calculate the element-wise sum of the vectors
v0 and v1,
saving the result to out. |
static <T,V extends PVectorWritable2IType<T> & PVectorReadable2IType<T>> |
addInPlace(V v0,
PVectorReadable2IType<T> v1)
Calculate the element-wise sum of the vectors
v0 and v1,
saving the result to v0. |
static <T,V extends PVectorWritable2IType<T>> |
addScaled(PVectorReadable2IType<T> v0,
PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> |
addScaledInPlace(V v0,
PVectorReadable2IType<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(PVectorReadable2IType<T> v0,
PVectorReadable2IType<T> v1)
Calculate the angle between vectors
v0 and v1, in radians. |
static <T,V extends PVectorWritable2IType<T>> |
clamp(PVectorReadable2IType<T> v,
int minimum,
int maximum,
V out)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <T,V extends PVectorWritable2IType<T>> |
clampByPVector(PVectorReadable2IType<T> v,
PVectorReadable2IType<T> minimum,
PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> |
clampByPVectorInPlace(V v,
PVectorReadable2IType<T> minimum,
PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> |
clampInPlace(V v,
int minimum,
int maximum)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <T,V extends PVectorWritable2IType<T>> |
clampMaximum(PVectorReadable2IType<T> v,
int maximum,
V out)
Clamp the elements of the vector
v to the range {@code [-Infinity
.. |
static <T,V extends PVectorWritable2IType<T>> |
clampMaximumByPVector(PVectorReadable2IType<T> v,
PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> |
clampMaximumByPVectorInPlace(V v,
PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> |
clampMaximumInPlace(V v,
int maximum)
Clamp the elements of the vector
v to the range {@code [-Infinity
.. |
static <T,V extends PVectorWritable2IType<T>> |
clampMinimum(PVectorReadable2IType<T> v,
int minimum,
V out)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <T,V extends PVectorWritable2IType<T>> |
clampMinimumByPVector(PVectorReadable2IType<T> v,
PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> |
clampMinimumByPVectorInPlace(V v,
PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> |
clampMinimumInPlace(V v,
int minimum)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <T,U extends PVectorWritable2IType<T>> |
copy(PVectorReadable2IType<T> input,
U output)
Copy all elements of the vector
input to the vector output. |
void |
copyFrom2I(VectorReadable2IType in_v)
Set the current vector to the contents of the input vector.
|
void |
copyFromTyped2I(PVectorReadable2IType<T> in_v)
Set the current vector to the contents of the input vector.
|
static <T> long |
distance(PVectorM2I.ContextPVM2I c,
PVectorReadable2IType<T> v0,
PVectorReadable2IType<T> v1)
Calculate the distance between the two vectors
v0 and v1. |
static <T> int |
dotProduct(PVectorReadable2IType<T> v0,
PVectorReadable2IType<T> v1)
Calculate the scalar product of the vectors
v0 and v1. |
boolean |
equals(Object obj) |
int |
getXI() |
int |
getYI() |
int |
hashCode() |
static <T,V extends PVectorWritable2IType<T>> |
interpolateLinear(PVectorM2I.ContextPVM2I c,
PVectorReadable2IType<T> v0,
PVectorReadable2IType<T> v1,
double alpha,
V r)
Linearly interpolate between
v0 and v1 by the amount alpha, saving the result to r. |
static <T> int |
magnitude(PVectorReadable2IType<T> v)
Calculate the magnitude of the vector
v. |
static <T> int |
magnitudeSquared(PVectorReadable2IType<T> v)
Calculate the squared magnitude of the vector
v. |
static <T,V extends PVectorWritable2IType<T>> |
projection(PVectorReadable2IType<T> p,
PVectorReadable2IType<T> q,
V r)
Calculate the projection of the vector
p onto the vector q,
saving the result in r. |
static <T,V extends PVectorWritable2IType<T>> |
scale(PVectorReadable2IType<T> v,
double r,
V out)
Scale the vector
v by the scalar r, saving the result to
out. |
static <T,V extends PVectorWritable2IType<T> & PVectorReadable2IType<T>> |
scaleInPlace(V v,
int r)
Scale the vector
v by the scalar r, saving the result to
v. |
void |
set2I(int in_x,
int in_y)
Set the current
x and y values of the current vector. |
void |
setXI(int in_x)
Set the current
x value of the current vector. |
void |
setYI(int in_y)
Set the current
y value of the current vector. |
static <T,V extends PVectorWritable2IType<T>> |
subtract(PVectorReadable2IType<T> v0,
PVectorReadable2IType<T> v1,
V out)
Subtract the vector
v1 from the vector v0, saving the
result to out. |
static <T,V extends PVectorWritable2IType<T> & PVectorReadable2IType<T>> |
subtractInPlace(V v0,
PVectorReadable2IType<T> v1)
Subtract the vector
v1 from the vector v0, saving the
result to v0. |
String |
toString() |
public PVectorM2I()
[0, 0,
0].public PVectorM2I(int in_x,
int in_y)
in_x - The x valuein_y - The y valuepublic PVectorM2I(PVectorReadable2IType<T> in_v)
in_v.in_v - The source vectorpublic static <T,V extends PVectorWritable2IType<T>> V absolute(PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<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 PVectorWritable2IType<T>> V add(PVectorReadable2IType<T> v0, PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> V addInPlace(V v0, PVectorReadable2IType<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 PVectorWritable2IType<T>> V addScaled(PVectorReadable2IType<T> v0, PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> V addScaledInPlace(V v0, PVectorReadable2IType<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(PVectorReadable2IType<T> v0, PVectorReadable2IType<T> v1)
v0 and v1, in radians.T - A phantom type parameterv0 - The left input vectorv1 - The right input vectorpublic static <T,V extends PVectorWritable2IType<T>> V clamp(PVectorReadable2IType<T> v, int minimum, int 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 PVectorWritable2IType<T>> V clampByPVector(PVectorReadable2IType<T> v, PVectorReadable2IType<T> minimum, PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> V clampByPVectorInPlace(V v, PVectorReadable2IType<T> minimum, PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> V clampInPlace(V v, int minimum, int 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 PVectorWritable2IType<T>> V clampMaximum(PVectorReadable2IType<T> v, int 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 PVectorWritable2IType<T>> V clampMaximumByPVector(PVectorReadable2IType<T> v, PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> V clampMaximumByPVectorInPlace(V v, PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> V clampMaximumInPlace(V v, int 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 PVectorWritable2IType<T>> V clampMinimum(PVectorReadable2IType<T> v, int 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 PVectorWritable2IType<T>> V clampMinimumByPVector(PVectorReadable2IType<T> v, PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> V clampMinimumByPVectorInPlace(V v, PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> V clampMinimumInPlace(V v, int 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 PVectorWritable2IType<T>> U copy(PVectorReadable2IType<T> input, U output)
input to the vector output.U - The specific type of vectorT - A phantom type parameterinput - The input vectoroutput - The output vectorpublic static <T> long distance(PVectorM2I.ContextPVM2I c, PVectorReadable2IType<T> v0, PVectorReadable2IType<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> int dotProduct(PVectorReadable2IType<T> v0, PVectorReadable2IType<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 PVectorWritable2IType<T>> V interpolateLinear(PVectorM2I.ContextPVM2I c, PVectorReadable2IType<T> v0, PVectorReadable2IType<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> int magnitude(PVectorReadable2IType<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> int magnitudeSquared(PVectorReadable2IType<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 PVectorWritable2IType<T>> V projection(PVectorReadable2IType<T> p, PVectorReadable2IType<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 PVectorWritable2IType<T>> V scale(PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> V scaleInPlace(V v, int 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 PVectorWritable2IType<T>> V subtract(PVectorReadable2IType<T> v0, PVectorReadable2IType<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 PVectorWritable2IType<T> & PVectorReadable2IType<T>> V subtractInPlace(V v0, PVectorReadable2IType<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 copyFrom2I(VectorReadable2IType in_v)
VectorWritable2ITypecopyFrom2I in interface VectorWritable2ITypein_v - The input vectorpublic void copyFromTyped2I(PVectorReadable2IType<T> in_v)
PVectorWritable2ITypecopyFromTyped2I in interface PVectorWritable2IType<T>in_v - The input vectorpublic int getXI()
getXI in interface VectorReadable2ITypepublic void setXI(int in_x)
VectorWritable2ITypex value of the current vector.setXI in interface VectorWritable2ITypein_x - The new x value.public int getYI()
getYI in interface VectorReadable2ITypepublic void setYI(int in_y)
VectorWritable2ITypey value of the current vector.setYI in interface VectorWritable2ITypein_y - The new y value.public void set2I(int in_x,
int in_y)
VectorWritable2ITypex and y values of the current vector.set2I in interface VectorWritable2ITypein_x - The new x value.in_y - The new y value.Copyright © 2015 <code@io7m.com> http://io7m.com