public class VectorI4F extends Object implements VectorReadable4FType
A four-dimensional immutable vector type with single precision elements.
Values of this type are immutable and can therefore be safely accessed from multiple threads.
| Constructor and Description |
|---|
VectorI4F()
Default constructor, initializing the vector with values
[0.0, 0.0, 0.0, 1.0]. |
VectorI4F(float in_x,
float in_y,
float in_z,
float in_w)
Construct a vector initialized with the given values.
|
VectorI4F(VectorReadable4FType in_v)
Construct a vector initialized with the values given in the vector
in_v. |
| Modifier and Type | Method and Description |
|---|---|
static VectorI4F |
absolute(VectorReadable4FType v)
Calculate the absolute value of the vector
v. |
static VectorI4F |
add(VectorReadable4FType v0,
VectorReadable4FType v1)
Calculate the element-wise sum of the vectors
v0 and
v1. |
static VectorI4F |
addScaled(VectorReadable4FType v0,
VectorReadable4FType v1,
float r)
Calculate the element-wise sum of the vectors
v0 and the
element-wise product of v1 and r. |
static boolean |
almostEqual(com.io7m.jequality.AlmostEqualFloat.ContextRelative context,
VectorReadable4FType va,
VectorReadable4FType vb)
Determine whether or not the vectors
va and vb
are equal to within the degree of error given in context. |
static VectorI4F |
clamp(VectorReadable4FType v,
float minimum,
float maximum)
Clamp the elements of the vector
v to the range
[minimum .. |
static VectorI4F |
clampByVector(VectorReadable4FType v,
VectorReadable4FType minimum,
VectorReadable4FType maximum)
Clamp the elements of the vector
v to the inclusive range
given by the corresponding elements in minimum and
maximum. |
static VectorI4F |
clampMaximum(VectorReadable4FType v,
float maximum)
Clamp the elements of the vector
v to the range
[-Infinity .. |
static VectorI4F |
clampMaximumByVector(VectorReadable4FType v,
VectorReadable4FType maximum)
Clamp the elements of the vector
v to the inclusive range
given by the corresponding elements in maximum. |
static VectorI4F |
clampMinimum(VectorReadable4FType v,
float minimum)
Clamp the elements of the vector
v to the range
[minimum .. |
static VectorI4F |
clampMinimumByVector(VectorReadable4FType v,
VectorReadable4FType minimum)
Clamp the elements of the vector
v to the inclusive range
given by the corresponding elements in minimum. |
static float |
distance(VectorReadable4FType v0,
VectorReadable4FType v1)
Calculate the distance between the two vectors
v0 and
v1. |
static float |
dotProduct(VectorReadable4FType v0,
VectorReadable4FType v1)
Calculate the scalar product of the vectors
v0 and
v1. |
boolean |
equals(Object obj) |
float |
getWF() |
float |
getXF() |
float |
getYF() |
float |
getZF() |
int |
hashCode() |
static VectorI4F |
interpolateLinear(VectorReadable4FType v0,
VectorReadable4FType v1,
float alpha)
Linearly interpolate between
v0 and v1 by the
amount alpha. |
static float |
magnitude(VectorReadable4FType v)
Calculate the magnitude of the vector
v. |
static float |
magnitudeSquared(VectorReadable4FType v)
Calculate the squared magnitude of the vector
v. |
static VectorI4F |
normalize(VectorReadable4FType v)
Normalize the vector
v, preserving its direction but
reducing it to unit length. |
static com.io7m.jfunctional.Pair<VectorI4F,VectorI4F> |
orthoNormalize(VectorReadable4FType v0,
VectorReadable4FType v1)
Orthonormalize and return the vectors
v0 and v1
. |
static VectorI4F |
projection(VectorReadable4FType p,
VectorReadable4FType q)
Calculate the projection of the vector
p onto the vector
q. |
static VectorI4F |
scale(VectorReadable4FType v,
float r)
Scale the vector
v by the scalar r. |
static VectorI4F |
subtract(VectorReadable4FType v0,
VectorReadable4FType v1)
Subtract the vector
v1 from the vector v0. |
String |
toString() |
public static final VectorI4F ZERO
public VectorI4F()
[0.0, 0.0, 0.0, 1.0].public VectorI4F(float in_x,
float in_y,
float in_z,
float in_w)
in_x - The x valuein_y - The y valuein_z - The z valuein_w - The w valuepublic VectorI4F(VectorReadable4FType in_v)
in_v.in_v - The source vectorpublic static final VectorI4F absolute(VectorReadable4FType v)
v.v - The input vector(abs v.getXF(), abs v.getYF(), abs v.getZF(), abs v.getWF())public static final VectorI4F add(VectorReadable4FType v0, VectorReadable4FType v1)
v0 and
v1.v0 - The left input vectorv1 - The right input vector(v0.getXF() + v1.getXF(), v0.getYF() + v1.getYF(), v0.getZF() + v1.getZF(), v0.getWF() + v1.getWF())public static final VectorI4F addScaled(VectorReadable4FType v0, VectorReadable4FType v1, float r)
v0 and the
element-wise product of v1 and r.v0 - The left input vectorv1 - The right input vectorr - The scaling value(v0.getXF() + (v1.getXF() * r), v0.getYF() + (v1.getYF() * r), v0.getZF() + (v1.getZF() * r), v0.getWF() + (v1.getWF() * r))public static final boolean almostEqual(com.io7m.jequality.AlmostEqualFloat.ContextRelative context,
VectorReadable4FType va,
VectorReadable4FType vb)
va and vb
are equal to within the degree of error given in context.context - The equality contextva - The left input vectorvb - The right input vectortrue iff the vectors are almost equal.AlmostEqualFloat.almostEqual(ContextRelative, float, float)public static final VectorI4F clamp(VectorReadable4FType v, float minimum, float 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 final VectorI4F clampByVector(VectorReadable4FType v, VectorReadable4FType minimum, VectorReadable4FType 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.getXF(), minimum.getXF()), maximum.getXF()),
min(max(v.getYF(), minimum.getYF()), maximum.getYF()),
min(max(v.getZF(), minimum.getZF()), maximum.getZF()),
min(max(v.getWF(), minimum.getWF()), maximum.getWF())
)public static final VectorI4F clampMaximum(VectorReadable4FType v, float maximum)
v to the range
[-Infinity .. maximum] inclusive.v - The input vectormaximum - The maximum allowed valuemaximumpublic static final VectorI4F clampMaximumByVector(VectorReadable4FType v, VectorReadable4FType 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.getXF(), maximum.getXF()), min(v.getYF(), maximum.getYF()), min(v.getZF(), maximum.getZF()), min(v.getWF(), maximum.getWF()))public static final VectorI4F clampMinimum(VectorReadable4FType v, float minimum)
v to the range
[minimum .. Infinity] inclusive.v - The input vectorminimum - The minimum allowed valueminimum.public static final VectorI4F clampMinimumByVector(VectorReadable4FType v, VectorReadable4FType 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.getXF(), minimum.getXF()), max(v.getYF(), minimum.getYF()), max(v.getZF(), minimum.getZF()), max(v.getWF(), minimum.getWF()))public static final float distance(VectorReadable4FType v0, VectorReadable4FType v1)
v0 and
v1.v0 - The left input vectorv1 - The right input vectorpublic static final float dotProduct(VectorReadable4FType v0, VectorReadable4FType v1)
v0 and
v1.v0 - The left input vectorv1 - The right input vectorpublic static final VectorI4F interpolateLinear(VectorReadable4FType v0, VectorReadable4FType v1, float alpha)
v0 and v1 by the
amount alpha.
The alpha parameter controls the degree of interpolation,
such that:
interpolateLinear(v0, v1, 0.0) = v0interpolateLinear(v0, v1, 1.0) = v1v0 - The left input vector.v1 - The right input vector.alpha - The interpolation value, between 0.0 and
1.0.(1 - alpha) * v0 + alpha * v1public static final float magnitude(VectorReadable4FType v)
v.
Correspondingly, magnitude(normalize(v)) == 1.0.v - The input vectorpublic static final float magnitudeSquared(VectorReadable4FType v)
v.v - The input vectorpublic static final VectorI4F normalize(VectorReadable4FType v)
v, preserving its direction but
reducing it to unit length.v - The input vectorv but with
magnitude equal to 1.0public static final com.io7m.jfunctional.Pair<VectorI4F,VectorI4F> orthoNormalize(VectorReadable4FType v0, VectorReadable4FType v1)
Orthonormalize and return the vectors v0 and v1
.
See GSP
v0 - The left vectorv1 - The right vector(v0, v1), orthonormalized.public static final VectorI4F projection(VectorReadable4FType p, VectorReadable4FType q)
p onto the vector
q.p - The left vectorq - The right vector((dotProduct p q) / magnitudeSquared q) * qpublic static final VectorI4F scale(VectorReadable4FType v, float r)
v by the scalar r.v - The input vectorr - The scaling value(v.getXF() * r, v.getYF() * r, v.getZF() * r, v.getWF() * r)public static final VectorI4F subtract(VectorReadable4FType v0, VectorReadable4FType v1)
v1 from the vector v0.v0 - The left input vectorv1 - The right input vector(v0.getXF() - v1.getXF(), v0.getYF() - v1.getYF(), v0.getZF() - v1.getZF())public final float getWF()
getWF in interface VectorReadable4FTypepublic final float getXF()
getXF in interface VectorReadable2FTypepublic final float getYF()
getYF in interface VectorReadable2FTypepublic final float getZF()
getZF in interface VectorReadable3FTypeCopyright © 2014 <code@io7m.com> http://io7m.com