public class VectorM4I extends Object implements VectorReadable4IType, VectorWritable4IType
A four-dimensional mutable vector type with integer elements.
Values of this type cannot be accessed safely from multiple threads without explicit synchronization.
| Constructor and Description |
|---|
VectorM4I()
Default constructor, initializing the vector with values
[0, 0, 0, 1]. |
VectorM4I(int in_x,
int in_y,
int in_z,
int in_w)
Construct a vector initialized with the given values.
|
VectorM4I(VectorReadable4IType in_v)
Construct a vector initialized with the values given in the vector
v. |
| Modifier and Type | Method and Description |
|---|---|
static VectorM4I |
absolute(VectorReadable4IType v,
VectorM4I out)
Calculate the absolute values of the elements in vector
v,
saving the result to out. |
static VectorM4I |
absoluteInPlace(VectorM4I v)
Calculate the absolute values of the elements in vector
v,
saving the result to v. |
static VectorM4I |
add(VectorReadable4IType v0,
VectorReadable4IType v1,
VectorM4I out)
Calculate the element-wise sum of the vectors
v0 and
v1, saving the result to out. |
static VectorM4I |
addInPlace(VectorM4I v0,
VectorReadable4IType v1)
Calculate the element-wise sum of the vectors
v0 and
v1, saving the result to v0. |
static VectorM4I |
addScaled(VectorReadable4IType v0,
VectorReadable4IType v1,
double r,
VectorM4I 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 VectorM4I |
addScaledInPlace(VectorM4I v0,
VectorReadable4IType 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 VectorM4I |
clamp(VectorReadable4IType v,
int minimum,
int maximum,
VectorM4I out)
Clamp the elements of the vector
v to the range
[minimum .. |
static VectorM4I |
clampByVector(VectorReadable4IType v,
VectorReadable4IType minimum,
VectorReadable4IType maximum,
VectorM4I 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 VectorM4I |
clampByVectorInPlace(VectorM4I v,
VectorReadable4IType minimum,
VectorReadable4IType 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 VectorM4I |
clampInPlace(VectorM4I v,
int minimum,
int maximum)
Clamp the elements of the vector
v to the range
[minimum .. |
static VectorM4I |
clampMaximum(VectorReadable4IType v,
int maximum,
VectorM4I out)
Clamp the elements of the vector
v to the range
[-Infinity .. |
static VectorM4I |
clampMaximumByVector(VectorReadable4IType v,
VectorReadable4IType maximum,
VectorM4I 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 VectorM4I |
clampMaximumByVectorInPlace(VectorM4I v,
VectorReadable4IType 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 VectorM4I |
clampMaximumInPlace(VectorM4I v,
int maximum)
Clamp the elements of the vector
v to the range
[-Infinity .. |
static VectorM4I |
clampMinimum(VectorReadable4IType v,
int minimum,
VectorM4I out)
Clamp the elements of the vector
v to the range
[minimum .. |
static VectorM4I |
clampMinimumByVector(VectorReadable4IType v,
VectorReadable4IType minimum,
VectorM4I 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 VectorM4I |
clampMinimumByVectorInPlace(VectorM4I v,
VectorReadable4IType 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 VectorM4I |
clampMinimumInPlace(VectorM4I v,
int minimum)
Clamp the elements of the vector
v to the range
[minimum .. |
static <T extends VectorWritable4IType> |
copy(VectorReadable4IType input,
T 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.
|
static int |
distance(VectorReadable4IType v0,
VectorReadable4IType v1)
Calculate the distance between the two vectors
v0 and
v1. |
static int |
dotProduct(VectorReadable4IType v0,
VectorReadable4IType 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 VectorM4I |
interpolateLinear(VectorReadable4IType v0,
VectorReadable4IType v1,
double alpha,
VectorM4I r)
Linearly interpolate between
v0 and v1 by the
amount alpha, saving the result to r. |
static int |
magnitude(VectorReadable4IType v)
Calculate the magnitude of the vector
v. |
static int |
magnitudeSquared(VectorReadable4IType v)
Calculate the squared magnitude of the vector
v. |
static VectorM4I |
projection(VectorReadable4IType p,
VectorReadable4IType q,
VectorM4I r)
Calculate the projection of the vector
p onto the vector
q, saving the result in r. |
static VectorM4I |
scale(VectorReadable4IType v,
double r,
VectorM4I out)
Scale the vector
v by the scalar r, saving the
result to out. |
static VectorM4I |
scaleInPlace(VectorM4I 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 VectorM4I |
subtract(VectorReadable4IType v0,
VectorReadable4IType v1,
VectorM4I out)
Subtract the vector
v1 from the vector v0,
saving the result to out. |
static VectorM4I |
subtractInPlace(VectorM4I v0,
VectorReadable4IType v1)
Subtract the vector
v1 from the vector v0,
saving the result to v0. |
String |
toString() |
public VectorM4I()
[0, 0, 0, 1].public VectorM4I(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 VectorM4I(VectorReadable4IType in_v)
v.in_v - The source vectorpublic static final VectorM4I absolute(VectorReadable4IType v, VectorM4I out) throws ArithmeticException
v,
saving the result to out.v - 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 final VectorM4I absoluteInPlace(VectorM4I v) throws ArithmeticException
v,
saving the result to v.v - 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 final VectorM4I add(VectorReadable4IType v0, VectorReadable4IType v1, VectorM4I out) throws ArithmeticException
v0 and
v1, saving the result to out.v0 - 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 final VectorM4I addInPlace(VectorM4I v0, VectorReadable4IType v1) throws ArithmeticException
v0 and
v1, saving the result to v0.v0 - 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 final VectorM4I addScaled(VectorReadable4IType v0, VectorReadable4IType v1, double r, VectorM4I out) throws ArithmeticException
v0 and the
element-wise product of v1 and r, saving the
result to out.v0 - 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 final VectorM4I addScaledInPlace(VectorM4I v0, VectorReadable4IType v1, double r) throws ArithmeticException
v0 and the
element-wise product of v1 and r, saving the
result to v0.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), v0.w + (v1.w * r))ArithmeticException - Iff an internal arithmetic operation causes an integer overflowpublic static final VectorM4I clamp(VectorReadable4IType v, int minimum, int maximum, VectorM4I out)
v to the range
[minimum .. maximum] inclusive, saving the result to
out.v - The input vectorminimum - The minimum allowed valuemaximum - The maximum allowed valueout - The output vectormaximum
and at least minimumpublic static final VectorM4I clampByVector(VectorReadable4IType v, VectorReadable4IType minimum, VectorReadable4IType maximum, VectorM4I out)
v to the inclusive range
given by the corresponding elements in minimum and
maximum, saving the result to out.v - 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 final VectorM4I clampByVectorInPlace(VectorM4I v, VectorReadable4IType minimum, VectorReadable4IType maximum)
v to the inclusive range
given by the corresponding elements in minimum and
maximum, saving the result to v.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), min(max(v.w, minimum.w), maximum.w))public static final VectorM4I clampInPlace(VectorM4I v, int minimum, int maximum)
v to the range
[minimum .. maximum] inclusive, saving the result to
v.v - The input vectorminimum - The minimum allowed valuemaximum - The maximum allowed valuemaximum
and at least minimum, in vpublic static final VectorM4I clampMaximum(VectorReadable4IType v, int maximum, VectorM4I out)
v to the range
[-Infinity .. maximum] inclusive, saving the result to
out.v - The input vectorout - The output vectormaximum - The maximum allowed valuemaximumpublic static final VectorM4I clampMaximumByVector(VectorReadable4IType v, VectorReadable4IType maximum, VectorM4I out)
v to the inclusive range
given by the corresponding elements in maximum, saving the
result to out.v - 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 final VectorM4I clampMaximumByVectorInPlace(VectorM4I v, VectorReadable4IType maximum)
v to the inclusive range
given by the corresponding elements in maximum, saving the
result to v.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), min(v.w, maximum.w))public static final VectorM4I clampMaximumInPlace(VectorM4I v, int maximum)
v to the range
[-Infinity .. maximum] inclusive, saving the result to
v.v - The input vectormaximum - The maximum allowed valuemaximum
, in vpublic static final VectorM4I clampMinimum(VectorReadable4IType v, int minimum, VectorM4I out)
v to the range
[minimum .. Infinity] inclusive, saving the result to
out.v - The input vectorout - The output vectorminimum - The minimum allowed valueminimumpublic static final VectorM4I clampMinimumByVector(VectorReadable4IType v, VectorReadable4IType minimum, VectorM4I out)
v to the inclusive range
given by the corresponding elements in minimum, saving the
result to out.v - 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 final VectorM4I clampMinimumByVectorInPlace(VectorM4I v, VectorReadable4IType minimum)
v to the inclusive range
given by the corresponding elements in minimum, saving the
result to v.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), max(v.w, minimum.w))
, in vpublic static final VectorM4I clampMinimumInPlace(VectorM4I v, int minimum)
v to the range
[minimum .. Infinity] inclusive, saving the result to
v.v - The input vectorminimum - The minimum allowed valueminimum, in v.public static final <T extends VectorWritable4IType> T copy(VectorReadable4IType input, T output)
input to the vector
output.T - The specific type of vectorinput - The input vectoroutput - The output vectorpublic static final int distance(VectorReadable4IType v0, VectorReadable4IType 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 final int dotProduct(VectorReadable4IType v0, VectorReadable4IType 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 final VectorM4I interpolateLinear(VectorReadable4IType v0, VectorReadable4IType v1, double alpha, VectorM4I 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 = v1v0 - 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 final int magnitude(VectorReadable4IType v) throws ArithmeticException
v.
Correspondingly, magnitude(normalize(v)) == 1.0.v - The input vectorArithmeticException - Iff an internal arithmetic operation causes an integer overflowpublic static final int magnitudeSquared(VectorReadable4IType v) throws ArithmeticException
v.v - The input vectorArithmeticException - Iff an internal arithmetic operation causes an integer overflowpublic static final VectorM4I projection(VectorReadable4IType p, VectorReadable4IType q, VectorM4I r) throws ArithmeticException
p onto the vector
q, saving the result in r.p - 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 final VectorM4I scale(VectorReadable4IType v, double r, VectorM4I out) throws ArithmeticException
v by the scalar r, saving the
result to out.v - 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 final VectorM4I scaleInPlace(VectorM4I v, int r) throws ArithmeticException
v by the scalar r, saving the
result to v.v - 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 final VectorM4I subtract(VectorReadable4IType v0, VectorReadable4IType v1, VectorM4I out) throws ArithmeticException
v1 from the vector v0,
saving the result to out.v0 - 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 final VectorM4I subtractInPlace(VectorM4I v0, VectorReadable4IType v1) throws ArithmeticException
v1 from the vector v0,
saving the result to v0.v0 - 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 final void copyFrom2I(VectorReadable2IType in_v)
VectorWritable2ITypecopyFrom2I in interface VectorWritable2ITypein_v - The input vectorpublic final void copyFrom3I(VectorReadable3IType in_v)
VectorWritable3ITypecopyFrom3I in interface VectorWritable3ITypein_v - The input vectorpublic final void copyFrom4I(VectorReadable4IType in_v)
VectorWritable4ITypecopyFrom4I in interface VectorWritable4ITypein_v - The input vectorpublic final int getWI()
getWI in interface VectorReadable4ITypepublic final int getXI()
getXI in interface VectorReadable2ITypepublic final int getYI()
getYI in interface VectorReadable2ITypepublic final int getZI()
getZI in interface VectorReadable3ITypepublic final 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 final 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 final 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.public final void setWI(int in_w)
VectorWritable4ITypew value of the current vector.setWI in interface VectorWritable4ITypein_w - The new w value.public final void setXI(int in_x)
VectorWritable2ITypex value of the current vector.setXI in interface VectorWritable2ITypein_x - The new x value.public final void setYI(int in_y)
VectorWritable2ITypey value of the current vector.setYI in interface VectorWritable2ITypein_y - The new y value.public final void setZI(int in_z)
VectorWritable3ITypez value of the current vector.setZI in interface VectorWritable3ITypein_z - The new z value.Copyright © 2014 <code@io7m.com> http://io7m.com