public final class VectorM3I extends Object implements Vector3IType
A three-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 |
VectorM3I.ContextVM3I
Preallocated storage to allow all vector functions to run without
allocating.
|
| Constructor and Description |
|---|
VectorM3I()
Default constructor, initializing the vector with values
[0, 0,
0]. |
VectorM3I(int in_x,
int in_y,
int in_z)
Construct a vector initialized with the given values.
|
VectorM3I(VectorReadable3IType in_v)
Construct a vector initialized with the values given in the vector
in_v. |
| Modifier and Type | Method and Description |
|---|---|
static <V extends VectorWritable3IType> |
absolute(VectorReadable3IType v,
V out)
Calculate the absolute values of the elements in vector
v, saving
the result to out. |
static <V extends VectorWritable3IType & VectorReadable3IType> |
absoluteInPlace(V v)
Calculate the absolute values of the elements in vector
v, saving
the result to v. |
static <V extends VectorWritable3IType> |
add(VectorReadable3IType v0,
VectorReadable3IType v1,
V out)
Calculate the element-wise sum of the vectors
v0 and v1,
saving the result to out. |
static <V extends VectorWritable3IType & VectorReadable3IType> |
addInPlace(V v0,
VectorReadable3IType v1)
Calculate the element-wise sum of the vectors
v0 and v1,
saving the result to v0. |
static <V extends VectorWritable3IType> |
addScaled(VectorReadable3IType v0,
VectorReadable3IType 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 <V extends VectorWritable3IType & VectorReadable3IType> |
addScaledInPlace(V v0,
VectorReadable3IType 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 <V extends VectorWritable3IType> |
clamp(VectorReadable3IType v,
int minimum,
int maximum,
V out)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <V extends VectorWritable3IType> |
clampByVector(VectorReadable3IType v,
VectorReadable3IType minimum,
VectorReadable3IType 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 <V extends VectorWritable3IType & VectorReadable3IType> |
clampByVectorInPlace(V v,
VectorReadable3IType minimum,
VectorReadable3IType 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 <V extends VectorWritable3IType & VectorReadable3IType> |
clampInPlace(V v,
int minimum,
int maximum)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <V extends VectorWritable3IType> |
clampMaximum(VectorReadable3IType v,
int maximum,
V out)
Clamp the elements of the vector
v to the range {@code [-Infinity
.. |
static <V extends VectorWritable3IType> |
clampMaximumByVector(VectorReadable3IType v,
VectorReadable3IType 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 <V extends VectorWritable3IType & VectorReadable3IType> |
clampMaximumByVectorInPlace(V v,
VectorReadable3IType 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 <V extends VectorWritable3IType & VectorReadable3IType> |
clampMaximumInPlace(V v,
int maximum)
Clamp the elements of the vector
v to the range {@code [-Infinity
.. |
static <V extends VectorWritable3IType> |
clampMinimum(VectorReadable3IType v,
int minimum,
V out)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <V extends VectorWritable3IType> |
clampMinimumByVector(VectorReadable3IType v,
VectorReadable3IType 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 <V extends VectorWritable3IType & VectorReadable3IType> |
clampMinimumByVectorInPlace(V v,
VectorReadable3IType 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 <V extends VectorWritable3IType & VectorReadable3IType> |
clampMinimumInPlace(V v,
int minimum)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <V extends VectorWritable3IType> |
copy(VectorReadable3IType input,
V 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.
|
static int |
distance(VectorM3I.ContextVM3I c,
VectorReadable3IType v0,
VectorReadable3IType v1)
Calculate the distance between the two vectors
v0 and v1. |
static int |
dotProduct(VectorReadable3IType v0,
VectorReadable3IType v1)
Calculate the scalar product of the vectors
v0 and v1. |
boolean |
equals(Object obj) |
int |
getXI() |
int |
getYI() |
int |
getZI() |
int |
hashCode() |
static <V extends VectorWritable3IType> |
interpolateLinear(VectorM3I.ContextVM3I c,
VectorReadable3IType v0,
VectorReadable3IType v1,
double alpha,
V r)
Linearly interpolate between
v0 and v1 by the amount alpha, saving the result to r. |
static int |
magnitude(VectorReadable3IType v)
Calculate the magnitude of the vector
v. |
static int |
magnitudeSquared(VectorReadable3IType v)
Calculate the squared magnitude of the vector
v. |
static <V extends VectorWritable3IType> |
projection(VectorReadable3IType p,
VectorReadable3IType q,
V r)
Calculate the projection of the vector
p onto the vector q,
saving the result in r. |
static <V extends VectorWritable3IType> |
scale(VectorReadable3IType v,
double r,
V out)
Scale the vector
v by the scalar r, saving the result to
out. |
static <V extends VectorWritable3IType & VectorReadable3IType> |
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 |
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 <V extends VectorWritable3IType> |
subtract(VectorReadable3IType v0,
VectorReadable3IType v1,
V out)
Subtract the vector
v1 from the vector v0, saving the
result to out. |
static <V extends VectorWritable3IType & VectorReadable3IType> |
subtractInPlace(V v0,
VectorReadable3IType v1)
Subtract the vector
v1 from the vector v0, saving the
result to v0. |
String |
toString() |
public VectorM3I()
[0, 0,
0].public VectorM3I(int in_x,
int in_y,
int in_z)
in_x - The x valuein_y - The y valuein_z - The z valuepublic VectorM3I(VectorReadable3IType in_v)
in_v.in_v - The source vectorpublic static <V extends VectorWritable3IType> V absolute(VectorReadable3IType v, V out) throws ArithmeticException
v, saving
the result to out.V - 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 <V extends VectorWritable3IType & VectorReadable3IType> V absoluteInPlace(V v) throws ArithmeticException
v, saving
the result to v.V - 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 <V extends VectorWritable3IType> V add(VectorReadable3IType v0, VectorReadable3IType v1, V out) throws ArithmeticException
v0 and v1,
saving the result to out.V - 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 <V extends VectorWritable3IType & VectorReadable3IType> V addInPlace(V v0, VectorReadable3IType v1) throws ArithmeticException
v0 and v1,
saving the result to v0.V - 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 <V extends VectorWritable3IType> V addScaled(VectorReadable3IType v0, VectorReadable3IType v1, double r, V out) throws ArithmeticException
v0 and the
element-wise product of v1 and r, saving the result to
out.V - 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 <V extends VectorWritable3IType & VectorReadable3IType> V addScaledInPlace(V v0, VectorReadable3IType v1, double r) throws ArithmeticException
v0 and the
element-wise product of v1 and r, saving the result to
v0.V - 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 <V extends VectorWritable3IType> V clamp(VectorReadable3IType v, int minimum, int maximum, V out)
v to the range [minimum ..
maximum] inclusive, saving the result to out.V - The precise type of vectorv - The input vectorminimum - The minimum allowed valuemaximum - The maximum allowed valueout - The output vectormaximum and at
least minimumpublic static <V extends VectorWritable3IType> V clampByVector(VectorReadable3IType v, VectorReadable3IType minimum, VectorReadable3IType maximum, V out)
v to the inclusive range given by
the corresponding elements in minimum and maximum, saving
the result to out.V - 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 <V extends VectorWritable3IType & VectorReadable3IType> V clampByVectorInPlace(V v, VectorReadable3IType minimum, VectorReadable3IType maximum)
v to the inclusive range given by
the corresponding elements in minimum and maximum, saving
the result to v.V - 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 <V extends VectorWritable3IType & VectorReadable3IType> V clampInPlace(V v, int minimum, int maximum)
v to the range [minimum ..
maximum] inclusive, saving the result to v.V - The precise type of vectorv - The input vectorminimum - The minimum allowed valuemaximum - The maximum allowed valuemaximum and at
least minimum, in vpublic static <V extends VectorWritable3IType> V clampMaximum(VectorReadable3IType v, int maximum, V out)
v to the range [-Infinity
.. maximum] inclusive, saving the result to out.V - The precise type of vectorv - The input vectorout - The output vectormaximum - The maximum allowed valuemaximumpublic static <V extends VectorWritable3IType> V clampMaximumByVector(VectorReadable3IType v, VectorReadable3IType maximum, V out)
v to the inclusive range given by
the corresponding elements in maximum, saving the result to out.V - 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 <V extends VectorWritable3IType & VectorReadable3IType> V clampMaximumByVectorInPlace(V v, VectorReadable3IType maximum)
v to the inclusive range given by
the corresponding elements in maximum, saving the result to v.V - 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 <V extends VectorWritable3IType & VectorReadable3IType> V clampMaximumInPlace(V v, int maximum)
v to the range [-Infinity
.. maximum] inclusive, saving the result to v.V - The precise type of vectorv - The input vectormaximum - The maximum allowed valuemaximum , in
vpublic static <V extends VectorWritable3IType> V clampMinimum(VectorReadable3IType v, int minimum, V out)
v to the range [minimum ..
Infinity] inclusive, saving the result to out.V - The precise type of vectorv - The input vectorout - The output vectorminimum - The minimum allowed valueminimumpublic static <V extends VectorWritable3IType> V clampMinimumByVector(VectorReadable3IType v, VectorReadable3IType minimum, V out)
v to the inclusive range given by
the corresponding elements in minimum, saving the result to out.V - 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 <V extends VectorWritable3IType & VectorReadable3IType> V clampMinimumByVectorInPlace(V v, VectorReadable3IType minimum)
v to the inclusive range given by
the corresponding elements in minimum, saving the result to v.V - 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 <V extends VectorWritable3IType & VectorReadable3IType> V clampMinimumInPlace(V v, int minimum)
v to the range [minimum ..
Infinity] inclusive, saving the result to v.V - The precise type of vectorv - The input vectorminimum - The minimum allowed valueminimum, in
v.public static <V extends VectorWritable3IType> V copy(VectorReadable3IType input, V output)
input to the vector output.V - The specific type of vectorinput - The input vectoroutput - The output vectorpublic static int distance(VectorM3I.ContextVM3I c, VectorReadable3IType v0, VectorReadable3IType v1) throws ArithmeticException
v0 and v1.c - Preallocated storagev0 - The left input vectorv1 - The right input vectorArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static int dotProduct(VectorReadable3IType v0, VectorReadable3IType v1) throws ArithmeticException
v0 and v1.v0 - The left input vectorv1 - The right input vectorArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <V extends VectorWritable3IType> V interpolateLinear(VectorM3I.ContextVM3I c, VectorReadable3IType v0, VectorReadable3IType 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 = v1V - 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 overflow.public static int magnitude(VectorReadable3IType v) throws ArithmeticException
v.
Correspondingly, magnitude(normalize(v)) == 1.0.v - The input vectorArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static int magnitudeSquared(VectorReadable3IType v) throws ArithmeticException
v.v - The input vectorArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static <V extends VectorWritable3IType> V projection(VectorReadable3IType p, VectorReadable3IType q, V r) throws ArithmeticException
p onto the vector q,
saving the result in r.V - 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 <V extends VectorWritable3IType> V scale(VectorReadable3IType v, double r, V out) throws ArithmeticException
v by the scalar r, saving the result to
out.V - 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 <V extends VectorWritable3IType & VectorReadable3IType> V scaleInPlace(V v, int r) throws ArithmeticException
v by the scalar r, saving the result to
v.V - 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 <V extends VectorWritable3IType> V subtract(VectorReadable3IType v0, VectorReadable3IType v1, V out) throws ArithmeticException
v1 from the vector v0, saving the
result to out.V - 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 <V extends VectorWritable3IType & VectorReadable3IType> V subtractInPlace(V v0, VectorReadable3IType v1) throws ArithmeticException
v1 from the vector v0, saving the
result to v0.V - 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 copyFrom3I(VectorReadable3IType in_v)
VectorWritable3ITypecopyFrom3I in interface VectorWritable3ITypein_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 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.Copyright © 2017 <code@io7m.com> http://io7m.com