public class VectorM4L extends Object implements VectorReadable4LType, VectorWritable4LType
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 |
|---|
VectorM4L()
Default constructor, initializing the vector with values
[0, 0, 0, 1]. |
VectorM4L(long in_x,
long in_y,
long in_z,
long in_w)
Construct a vector initialized with the given values.
|
VectorM4L(VectorReadable4LType in_v)
Construct a vector initialized with the values given in the vector
in_v. |
| Modifier and Type | Method and Description |
|---|---|
static VectorM4L |
absolute(VectorReadable4LType v,
VectorM4L out)
Calculate the absolute values of the elements in vector
v,
saving the result to out. |
static VectorM4L |
absoluteInPlace(VectorM4L v)
Calculate the absolute values of the elements in vector
v,
saving the result to v. |
static VectorM4L |
add(VectorReadable4LType v0,
VectorReadable4LType v1,
VectorM4L out)
Calculate the element-wise sum of the vectors
v0 and
v1, saving the result to out. |
static VectorM4L |
addInPlace(VectorM4L v0,
VectorReadable4LType v1)
Calculate the element-wise sum of the vectors
v0 and
v1, saving the result to v0. |
static VectorM4L |
addScaled(VectorReadable4LType v0,
VectorReadable4LType v1,
double r,
VectorM4L 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 VectorM4L |
addScaledInPlace(VectorM4L v0,
VectorReadable4LType 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 VectorM4L |
clamp(VectorReadable4LType v,
long minimum,
long maximum,
VectorM4L out)
Clamp the elements of the vector
v to the range
[minimum .. |
static VectorM4L |
clampByVector(VectorReadable4LType v,
VectorReadable4LType minimum,
VectorReadable4LType maximum,
VectorM4L 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 VectorM4L |
clampByVectorInPlace(VectorM4L v,
VectorReadable4LType minimum,
VectorReadable4LType 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 VectorM4L |
clampInPlace(VectorM4L v,
long minimum,
long maximum)
Clamp the elements of the vector
v to the range
[minimum .. |
static VectorM4L |
clampMaximum(VectorReadable4LType v,
long maximum,
VectorM4L out)
Clamp the elements of the vector
v to the range
[-Infinity .. |
static VectorM4L |
clampMaximumByVector(VectorReadable4LType v,
VectorReadable4LType maximum,
VectorM4L 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 VectorM4L |
clampMaximumByVectorInPlace(VectorM4L v,
VectorReadable4LType 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 VectorM4L |
clampMaximumInPlace(VectorM4L v,
long maximum)
Clamp the elements of the vector
v to the range
[-Infinity .. |
static VectorM4L |
clampMinimum(VectorReadable4LType v,
long minimum,
VectorM4L out)
Clamp the elements of the vector
v to the range
[minimum .. |
static VectorM4L |
clampMinimumByVector(VectorReadable4LType v,
VectorReadable4LType minimum,
VectorM4L 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 VectorM4L |
clampMinimumByVectorInPlace(VectorM4L v,
VectorReadable4LType 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 VectorM4L |
clampMinimumInPlace(VectorM4L v,
long minimum)
Clamp the elements of the vector
v to the range
[minimum .. |
static <T extends VectorWritable4LType> |
copy(VectorReadable4LType input,
T output)
Copy all elements of the vector
input to the vector
output. |
void |
copyFrom2L(VectorReadable2LType in_v)
Set the current vector to the contents of the input vector.
|
void |
copyFrom3L(VectorReadable3LType in_v)
Set the current vector to the contents of the input vector.
|
void |
copyFrom4L(VectorReadable4LType in_v)
Set the current vector to the contents of the input vector.
|
static long |
distance(VectorReadable4LType v0,
VectorReadable4LType v1)
Calculate the distance between the two vectors
v0 and
v1. |
static long |
dotProduct(VectorReadable4LType v0,
VectorReadable4LType v1)
Calculate the scalar product of the vectors
v0 and
v1. |
boolean |
equals(Object obj) |
long |
getWL() |
long |
getXL() |
long |
getYL() |
long |
getZL() |
int |
hashCode() |
static VectorM4L |
interpolateLinear(VectorReadable4LType v0,
VectorReadable4LType v1,
double alpha,
VectorM4L r)
Linearly interpolate between
v0 and v1 by the
amount alpha, saving the result to r. |
static long |
magnitude(VectorReadable4LType v)
Calculate the magnitude of the vector
v. |
static long |
magnitudeSquared(VectorReadable4LType v)
Calculate the squared magnitude of the vector
v. |
static VectorM4L |
projection(VectorReadable4LType p,
VectorReadable4LType q,
VectorM4L r)
Calculate the projection of the vector
p onto the vector
q, saving the result in r. |
static VectorM4L |
scale(VectorReadable4LType v,
double r,
VectorM4L out)
Scale the vector
v by the scalar r, saving the
result to out. |
static VectorM4L |
scaleInPlace(VectorM4L v,
long r)
Scale the vector
v by the scalar r, saving the
result to v. |
void |
set2L(long in_x,
long in_y)
Set the current
x and y values of the current
vector. |
void |
set3L(long in_x,
long in_y,
long in_z)
Set the current
x, y and z values
of the current vector. |
void |
set4L(long in_x,
long in_y,
long in_z,
long in_w)
Set the current
x, y, z and
w values of the current vector. |
void |
setWL(long in_w)
Set the current
w value of the current vector. |
void |
setXL(long in_x)
Set the current
x value of the current vector. |
void |
setYL(long in_y)
Set the current
y value of the current vector. |
void |
setZL(long in_z)
Set the current
z value of the current vector. |
static VectorM4L |
subtract(VectorReadable4LType v0,
VectorReadable4LType v1,
VectorM4L out)
Subtract the vector
v1 from the vector v0,
saving the result to out. |
static VectorM4L |
subtractInPlace(VectorM4L v0,
VectorReadable4LType v1)
Subtract the vector
v1 from the vector v0,
saving the result to v0. |
String |
toString() |
public VectorM4L()
[0, 0, 0, 1].public VectorM4L(long in_x,
long in_y,
long in_z,
long in_w)
in_x - The x valuein_y - The y valuein_z - The z valuein_w - The w valuepublic VectorM4L(VectorReadable4LType in_v)
in_v.in_v - The source vectorpublic static final VectorM4L absolute(VectorReadable4LType v, VectorM4L 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 VectorM4L absoluteInPlace(VectorM4L 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 VectorM4L add(VectorReadable4LType v0, VectorReadable4LType v1, VectorM4L 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 VectorM4L addInPlace(VectorM4L v0, VectorReadable4LType 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 VectorM4L addScaled(VectorReadable4LType v0, VectorReadable4LType v1, double r, VectorM4L 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 VectorM4L addScaledInPlace(VectorM4L v0, VectorReadable4LType 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 VectorM4L clamp(VectorReadable4LType v, long minimum, long maximum, VectorM4L 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 VectorM4L clampByVector(VectorReadable4LType v, VectorReadable4LType minimum, VectorReadable4LType maximum, VectorM4L 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 VectorM4L clampByVectorInPlace(VectorM4L v, VectorReadable4LType minimum, VectorReadable4LType 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 VectorM4L clampInPlace(VectorM4L v, long minimum, long 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 VectorM4L clampMaximum(VectorReadable4LType v, long maximum, VectorM4L 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 VectorM4L clampMaximumByVector(VectorReadable4LType v, VectorReadable4LType maximum, VectorM4L 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 VectorM4L clampMaximumByVectorInPlace(VectorM4L v, VectorReadable4LType 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 VectorM4L clampMaximumInPlace(VectorM4L v, long 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 VectorM4L clampMinimum(VectorReadable4LType v, long minimum, VectorM4L 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 VectorM4L clampMinimumByVector(VectorReadable4LType v, VectorReadable4LType minimum, VectorM4L 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 VectorM4L clampMinimumByVectorInPlace(VectorM4L v, VectorReadable4LType 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 VectorM4L clampMinimumInPlace(VectorM4L v, long 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 VectorWritable4LType> T copy(VectorReadable4LType input, T output)
input to the vector
output.T - The specific vector typeinput - The input vectoroutput - The output vectorpublic static final long distance(VectorReadable4LType v0, VectorReadable4LType 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 long dotProduct(VectorReadable4LType v0, VectorReadable4LType 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 VectorM4L interpolateLinear(VectorReadable4LType v0, VectorReadable4LType v1, double alpha, VectorM4L 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 long magnitude(VectorReadable4LType 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 long magnitudeSquared(VectorReadable4LType v) throws ArithmeticException
v.v - The input vectorArithmeticException - Iff an internal arithmetic operation causes an integer overflowpublic static final VectorM4L projection(VectorReadable4LType p, VectorReadable4LType q, VectorM4L 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 VectorM4L scale(VectorReadable4LType v, double r, VectorM4L 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 VectorM4L scaleInPlace(VectorM4L v, long 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 VectorM4L subtract(VectorReadable4LType v0, VectorReadable4LType v1, VectorM4L 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 VectorM4L subtractInPlace(VectorM4L v0, VectorReadable4LType 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 copyFrom2L(VectorReadable2LType in_v)
VectorWritable2LTypecopyFrom2L in interface VectorWritable2LTypein_v - The input vectorpublic final void copyFrom3L(VectorReadable3LType in_v)
VectorWritable3LTypecopyFrom3L in interface VectorWritable3LTypein_v - The input vectorpublic final void copyFrom4L(VectorReadable4LType in_v)
VectorWritable4LTypecopyFrom4L in interface VectorWritable4LTypein_v - The input vectorpublic final long getWL()
getWL in interface VectorReadable4LTypepublic final long getXL()
getXL in interface VectorReadable2LTypepublic final long getYL()
getYL in interface VectorReadable2LTypepublic final long getZL()
getZL in interface VectorReadable3LTypepublic final void set2L(long in_x,
long in_y)
VectorWritable2LTypex and y values of the current
vector.set2L in interface VectorWritable2LTypein_x - The new x value.in_y - The new y value.public final void set3L(long in_x,
long in_y,
long in_z)
VectorWritable3LTypex, y and z values
of the current vector.set3L in interface VectorWritable3LTypein_x - The new x value.in_y - The new y value.in_z - The new z value.public final void set4L(long in_x,
long in_y,
long in_z,
long in_w)
VectorWritable4LTypex, y, z and
w values of the current vector.set4L in interface VectorWritable4LTypein_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 setWL(long in_w)
VectorWritable4LTypew value of the current vector.setWL in interface VectorWritable4LTypein_w - The new w value.public final void setXL(long in_x)
VectorWritable2LTypex value of the current vector.setXL in interface VectorWritable2LTypein_x - The new x value.public final void setYL(long in_y)
VectorWritable2LTypey value of the current vector.setYL in interface VectorWritable2LTypein_y - The new y value.public final void setZL(long in_z)
VectorWritable3LTypez value of the current vector.setZL in interface VectorWritable3LTypein_z - The new z value.Copyright © 2014 <code@io7m.com> http://io7m.com