@Immutable public final class VectorI3I extends Object implements VectorReadable3IType
A three-dimensional immutable vector type with integer elements.
Values of this type are immutable and can therefore be safely accessed from multiple threads.
| Constructor and Description |
|---|
VectorI3I()
Default constructor, initializing the vector with values
[0, 0,
0]. |
VectorI3I(int in_x,
int in_y,
int in_z)
Construct a vector initialized with the given values.
|
VectorI3I(VectorReadable3IType in_v)
Construct a vector initialized with the values given in the vector
in_v. |
| Modifier and Type | Method and Description |
|---|---|
static VectorI3I |
absolute(VectorReadable3IType v)
Calculate the absolute values of the elements in vector
v. |
static VectorI3I |
add(VectorReadable3IType v0,
VectorReadable3IType v1)
Calculate the element-wise sum of the vectors
v0 and v1. |
static VectorI3I |
addScaled(VectorReadable3IType v0,
VectorReadable3IType v1,
double r)
Calculate the element-wise sum of the vectors
v0 and the
element-wise product of v1 and r. |
static VectorI3I |
clamp(VectorReadable3IType v,
int minimum,
int maximum)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static VectorI3I |
clampByVector(VectorReadable3IType 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. |
static VectorI3I |
clampMaximum(VectorReadable3IType v,
int maximum)
Clamp the elements of the vector
v to the range {@code [-Infinity
.. |
static VectorI3I |
clampMaximumByVector(VectorReadable3IType v,
VectorReadable3IType maximum)
Clamp the elements of the vector
v to the inclusive range given by
the corresponding elements in maximum. |
static VectorI3I |
clampMinimum(VectorReadable3IType v,
int minimum)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static VectorI3I |
clampMinimumByVector(VectorReadable3IType v,
VectorReadable3IType minimum)
Clamp the elements of the vector
v to the inclusive range given by
the corresponding elements in minimum. |
static int |
distance(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 VectorI3I |
interpolateLinear(VectorReadable3IType v0,
VectorReadable3IType v1,
double alpha)
Linearly interpolate between
v0 and v1 by the amount alpha. |
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 VectorI3I |
projection(VectorReadable3IType p,
VectorReadable3IType q)
Calculate the projection of the vector
p onto the vector q. |
static VectorI3I |
scale(VectorReadable3IType v,
double r)
Scale the vector
v by the scalar r, saving the result to
out. |
static VectorI3I |
subtract(VectorReadable3IType v0,
VectorReadable3IType v1)
Subtract the vector
v1 from the vector v0. |
String |
toString() |
public static final VectorI3I ZERO
public VectorI3I()
[0, 0,
0].public VectorI3I(int in_x,
int in_y,
int in_z)
in_x - The x valuein_y - The y valuein_z - The z valuepublic VectorI3I(VectorReadable3IType in_v)
in_v.in_v - The source vectorpublic static VectorI3I absolute(VectorReadable3IType v) throws ArithmeticException
v.v - The input vector(abs v.x, abs v.y, abs v.z)ArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static VectorI3I add(VectorReadable3IType v0, VectorReadable3IType v1) throws ArithmeticException
v0 and v1.v0 - 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 VectorI3I addScaled(VectorReadable3IType v0, VectorReadable3IType v1, double r) throws ArithmeticException
v0 and the
element-wise product of v1 and r.v0 - 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 VectorI3I clamp(VectorReadable3IType v, int minimum, int maximum)
v to the range [minimum ..
maximum] inclusive.v - The input vectorminimum - The minimum allowed valuemaximum - The maximum allowed valuemaximum and at
least minimumpublic static VectorI3I clampByVector(VectorReadable3IType v, VectorReadable3IType minimum, VectorReadable3IType maximum)
v to the inclusive range given by
the corresponding elements in minimum and maximum.v - 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 VectorI3I clampMaximum(VectorReadable3IType v, int maximum)
v to the range [-Infinity
.. maximum] inclusive.v - The input vectormaximum - The maximum allowed valuemaximumpublic static VectorI3I clampMaximumByVector(VectorReadable3IType v, VectorReadable3IType maximum)
v to the inclusive range given by
the corresponding elements in maximum.v - 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 VectorI3I clampMinimum(VectorReadable3IType v, int minimum)
v to the range [minimum ..
Infinity] inclusive.v - The input vectorminimum - The minimum allowed valueminimumpublic static VectorI3I clampMinimumByVector(VectorReadable3IType v, VectorReadable3IType minimum)
v to the inclusive range given by
the corresponding elements in minimum.v - 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))public static int distance(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 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 VectorI3I interpolateLinear(VectorReadable3IType v0, VectorReadable3IType v1, double alpha) throws ArithmeticException
v0 and v1 by the amount alpha.
The alpha parameter controls the degree of interpolation, such
that:
interpolateLinear(v0, v1, 0.0, r) -> r = v0interpolateLinear(v0, v1, 1.0, r) -> r = v1v0 - The left input vector.v1 - The right input vector.alpha - The interpolation value, between 0.0 and 1.0.(1 - alpha) * v0 + alpha * v1ArithmeticException - 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 VectorI3I projection(VectorReadable3IType p, VectorReadable3IType q) throws ArithmeticException
p onto the vector q.q - The right vectorp - The left vector((dotProduct p q) / magnitudeSquared q) * qArithmeticException - Iff an internal arithmetic operation causes an
integer overflowpublic static VectorI3I scale(VectorReadable3IType v, double r) throws ArithmeticException
v by the scalar r, saving the result to
out.v - 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 VectorI3I subtract(VectorReadable3IType v0, VectorReadable3IType v1) throws ArithmeticException
v1 from the vector v0.v0 - 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 int getXI()
getXI in interface VectorReadable2ITypepublic int getYI()
getYI in interface VectorReadable2ITypepublic int getZI()
getZI in interface VectorReadable3ITypeCopyright © 2015 <code@io7m.com> http://io7m.com