T - A phantom type parameterpublic final class PVectorM4I<T> extends Object implements PVector4IType<T>
A four-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 |
PVectorM4I.ContextPVM4I
Preallocated storage to allow all vector functions to run without
allocating.
|
| Constructor and Description |
|---|
PVectorM4I()
Default constructor, initializing the vector with values
[0, 0, 0,
1]. |
PVectorM4I(int in_x,
int in_y,
int in_z,
int in_w)
Construct a vector initialized with the given values.
|
PVectorM4I(PVectorReadable4IType<T> in_v)
Construct a vector initialized with the values given in the vector
v. |
| Modifier and Type | Method and Description |
|---|---|
static <T,V extends PVectorWritable4IType<T>> |
absolute(PVectorReadable4IType<T> v,
V out)
Calculate the absolute values of the elements in vector
v, saving
the result to out. |
static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<T>> |
absoluteInPlace(V v)
Calculate the absolute values of the elements in vector
v, saving
the result to v. |
static <T,V extends PVectorWritable4IType<T>> |
add(PVectorReadable4IType<T> v0,
PVectorReadable4IType<T> v1,
V out)
Calculate the element-wise sum of the vectors
v0 and v1,
saving the result to out. |
static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<T>> |
addInPlace(V v0,
PVectorReadable4IType<T> v1)
Calculate the element-wise sum of the vectors
v0 and v1,
saving the result to v0. |
static <T,V extends PVectorWritable4IType<T>> |
addScaled(PVectorReadable4IType<T> v0,
PVectorReadable4IType<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 PVectorWritable4IType<T> & PVectorReadable4IType<T>> |
addScaledInPlace(V v0,
PVectorReadable4IType<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,V extends PVectorWritable4IType<T>> |
clamp(PVectorReadable4IType<T> v,
int minimum,
int maximum,
V out)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <T,V extends PVectorWritable4IType<T>> |
clampByPVector(PVectorReadable4IType<T> v,
PVectorReadable4IType<T> minimum,
PVectorReadable4IType<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 PVectorWritable4IType<T> & PVectorReadable4IType<T>> |
clampByPVectorInPlace(V v,
PVectorReadable4IType<T> minimum,
PVectorReadable4IType<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 PVectorWritable4IType<T> & PVectorReadable4IType<T>> |
clampInPlace(V v,
int minimum,
int maximum)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <T,V extends PVectorWritable4IType<T>> |
clampMaximum(PVectorReadable4IType<T> v,
int maximum,
V out)
Clamp the elements of the vector
v to the range {@code [-Infinity
.. |
static <T,V extends PVectorWritable4IType<T>> |
clampMaximumByPVector(PVectorReadable4IType<T> v,
PVectorReadable4IType<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 PVectorWritable4IType<T> & PVectorReadable4IType<T>> |
clampMaximumByPVectorInPlace(V v,
PVectorReadable4IType<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 PVectorWritable4IType<T> & PVectorReadable4IType<T>> |
clampMaximumInPlace(V v,
int maximum)
Clamp the elements of the vector
v to the range {@code [-Infinity
.. |
static <T,V extends PVectorWritable4IType<T>> |
clampMinimum(PVectorReadable4IType<T> v,
int minimum,
V out)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <T,V extends PVectorWritable4IType<T>> |
clampMinimumByPVector(PVectorReadable4IType<T> v,
PVectorReadable4IType<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 PVectorWritable4IType<T> & PVectorReadable4IType<T>> |
clampMinimumByPVectorInPlace(V v,
PVectorReadable4IType<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 PVectorWritable4IType<T> & PVectorReadable4IType<T>> |
clampMinimumInPlace(V v,
int minimum)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <T,U extends PVectorWritable4IType<T>> |
copy(PVectorReadable4IType<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 |
copyFrom3I(VectorReadable3IType in_v)
Set the current vector to the contents of the input vector.
|
void |
copyFrom4I(VectorReadable4IType 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.
|
void |
copyFromTyped3I(PVectorReadable3IType<T> in_v)
Set the current vector to the contents of the input vector.
|
void |
copyFromTyped4I(PVectorReadable4IType<T> in_v)
Set the current vector to the contents of the input vector.
|
static <T> int |
distance(PVectorM4I.ContextPVM4I c,
PVectorReadable4IType<T> v0,
PVectorReadable4IType<T> v1)
Calculate the distance between the two vectors
v0 and v1. |
static <T> int |
dotProduct(PVectorReadable4IType<T> v0,
PVectorReadable4IType<T> v1)
Calculate the scalar product of the vectors
v0 and v1. |
boolean |
equals(Object obj) |
int |
getWI() |
int |
getXI() |
int |
getYI() |
int |
getZI() |
int |
hashCode() |
static <T,V extends PVectorWritable4IType<T>> |
interpolateLinear(PVectorM4I.ContextPVM4I c,
PVectorReadable4IType<T> v0,
PVectorReadable4IType<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(PVectorReadable4IType<T> v)
Calculate the magnitude of the vector
v. |
static <T> int |
magnitudeSquared(PVectorReadable4IType<T> v)
Calculate the squared magnitude of the vector
v. |
static <T,V extends PVectorWritable4IType<T>> |
projection(PVectorReadable4IType<T> p,
PVectorReadable4IType<T> q,
V r)
Calculate the projection of the vector
p onto the vector q,
saving the result in r. |
static <T,V extends PVectorWritable4IType<T>> |
scale(PVectorReadable4IType<T> v,
double r,
V out)
Scale the vector
v by the scalar r, saving the result to
out. |
static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<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 |
set3I(int in_x,
int in_y,
int in_z)
Set the current
x, y and z values of the current
vector. |
void |
set4I(int in_x,
int in_y,
int in_z,
int in_w)
Set the current
x, y, z and w values of the
current vector. |
void |
setWI(int in_w)
Set the current
w value 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. |
void |
setZI(int in_z)
Set the current
z value of the current vector. |
static <T,V extends PVectorWritable4IType<T>> |
subtract(PVectorReadable4IType<T> v0,
PVectorReadable4IType<T> v1,
V out)
Subtract the vector
v1 from the vector v0, saving the
result to out. |
static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<T>> |
subtractInPlace(V v0,
PVectorReadable4IType<T> v1)
Subtract the vector
v1 from the vector v0, saving the
result to v0. |
String |
toString() |
public PVectorM4I()
[0, 0, 0,
1].public PVectorM4I(int in_x,
int in_y,
int in_z,
int in_w)
in_x - The x valuein_y - The y valuein_z - The z valuein_w - The w valuepublic PVectorM4I(PVectorReadable4IType<T> in_v)
v.in_v - The source vectorpublic static <T,V extends PVectorWritable4IType<T>> V absolute(PVectorReadable4IType<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, abs.w)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<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, abs.w)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable4IType<T>> V add(PVectorReadable4IType<T> v0, PVectorReadable4IType<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, v0.w + v1.w)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<T>> V addInPlace(V v0, PVectorReadable4IType<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, v0.w + v1.w)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable4IType<T>> V addScaled(PVectorReadable4IType<T> v0, PVectorReadable4IType<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),
v0.w + (v1.w * r))ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<T>> V addScaledInPlace(V v0, PVectorReadable4IType<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),
v0.w + (v1.w * r))ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable4IType<T>> V clamp(PVectorReadable4IType<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 PVectorWritable4IType<T>> V clampByPVector(PVectorReadable4IType<T> v, PVectorReadable4IType<T> minimum, PVectorReadable4IType<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), min(max(v.w,
minimum.w), maximum.w))public static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<T>> V clampByPVectorInPlace(V v, PVectorReadable4IType<T> minimum, PVectorReadable4IType<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), min(max(v.w,
minimum.w), maximum.w))public static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<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 PVectorWritable4IType<T>> V clampMaximum(PVectorReadable4IType<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 PVectorWritable4IType<T>> V clampMaximumByPVector(PVectorReadable4IType<T> v, PVectorReadable4IType<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), min(v.w, maximum.w))public static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<T>> V clampMaximumByPVectorInPlace(V v, PVectorReadable4IType<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), min(v.w, maximum.w))public static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<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 PVectorWritable4IType<T>> V clampMinimum(PVectorReadable4IType<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 PVectorWritable4IType<T>> V clampMinimumByPVector(PVectorReadable4IType<T> v, PVectorReadable4IType<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), max(v.w, minimum.w))public static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<T>> V clampMinimumByPVectorInPlace(V v, PVectorReadable4IType<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), max(v.w, minimum.w)) , in vpublic static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<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 PVectorWritable4IType<T>> U copy(PVectorReadable4IType<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> int distance(PVectorM4I.ContextPVM4I c, PVectorReadable4IType<T> v0, PVectorReadable4IType<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(PVectorReadable4IType<T> v0, PVectorReadable4IType<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 PVectorWritable4IType<T>> V interpolateLinear(PVectorM4I.ContextPVM4I c, PVectorReadable4IType<T> v0, PVectorReadable4IType<T> v1, double alpha, V r) throws ArithmeticException
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 vector.v1 - The right input vector.alpha - The interpolation value, between 0.0 and 1.0.r - The result vector.rArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T> int magnitude(PVectorReadable4IType<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(PVectorReadable4IType<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 PVectorWritable4IType<T>> V projection(PVectorReadable4IType<T> p, PVectorReadable4IType<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 PVectorWritable4IType<T>> V scale(PVectorReadable4IType<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, v.w * r)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<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, v.w * r)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable4IType<T>> V subtract(PVectorReadable4IType<T> v0, PVectorReadable4IType<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, v0.w - v1.w)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <T,V extends PVectorWritable4IType<T> & PVectorReadable4IType<T>> V subtractInPlace(V v0, PVectorReadable4IType<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, v0.w - v1.w)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic void copyFrom2I(VectorReadable2IType in_v)
VectorWritable2ITypecopyFrom2I in interface VectorWritable2ITypein_v - The input vectorpublic void copyFrom3I(VectorReadable3IType in_v)
VectorWritable3ITypecopyFrom3I in interface VectorWritable3ITypein_v - The input vectorpublic void copyFrom4I(VectorReadable4IType in_v)
VectorWritable4ITypecopyFrom4I in interface VectorWritable4ITypein_v - The input vectorpublic void copyFromTyped2I(PVectorReadable2IType<T> in_v)
PVectorWritable2ITypecopyFromTyped2I in interface PVectorWritable2IType<T>in_v - The input vectorpublic void copyFromTyped3I(PVectorReadable3IType<T> in_v)
PVectorWritable3ITypecopyFromTyped3I in interface PVectorWritable3IType<T>in_v - The input vectorpublic void copyFromTyped4I(PVectorReadable4IType<T> in_v)
PVectorWritable4ITypecopyFromTyped4I in interface PVectorWritable4IType<T>in_v - The input vectorpublic int getWI()
getWI in interface VectorReadable4ITypepublic void setWI(int in_w)
VectorWritable4ITypew value of the current vector.setWI in interface VectorWritable4ITypein_w - The new w value.public 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 int getZI()
getZI in interface VectorReadable3ITypepublic void setZI(int in_z)
VectorWritable3ITypez value of the current vector.setZI in interface VectorWritable3ITypein_z - The new z 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.public void set3I(int in_x,
int in_y,
int in_z)
VectorWritable3ITypex, y and z values of the current
vector.set3I in interface VectorWritable3ITypein_x - The new x value.in_y - The new y value.in_z - The new z value.public void set4I(int in_x,
int in_y,
int in_z,
int in_w)
VectorWritable4ITypex, y, z and w values of the
current vector.set4I in interface VectorWritable4ITypein_x - The new x value.in_y - The new y value.in_z - The new z value.in_w - The new w value.Copyright © 2015 <code@io7m.com> http://io7m.com