public class VectorI3F extends Object implements VectorReadable3FType
A three-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 |
|---|
VectorI3F()
Default constructor, initializing the vector with values
[0.0, 0.0, 0.0]. |
VectorI3F(float in_x,
float in_y,
float in_z)
Construct a vector initialized with the given values.
|
VectorI3F(VectorReadable3FType in_v)
Construct a vector initialized with the values given in the vector
in_v. |
| Modifier and Type | Method and Description |
|---|---|
static VectorI3F |
absolute(VectorReadable3FType v)
Calculate the absolute value of the vector
v. |
static VectorI3F |
add(VectorReadable3FType v0,
VectorReadable3FType v1)
Calculate the element-wise sum of the vectors
v0 and
v1. |
static VectorI3F |
addScaled(VectorReadable3FType v0,
VectorReadable3FType 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,
VectorReadable3FType va,
VectorReadable3FType vb)
Determine whether or not the vectors
va and vb
are equal to within the degree of error given in context. |
static VectorI3F |
clamp(VectorReadable3FType v,
float minimum,
float maximum)
Clamp the elements of the vector
v to the range
[minimum .. |
static VectorI3F |
clampByVector(VectorReadable3FType v,
VectorReadable3FType minimum,
VectorReadable3FType maximum)
Clamp the elements of the vector
v to the inclusive range
given by the corresponding elements in minimum and
maximum. |
static VectorI3F |
clampMaximum(VectorReadable3FType v,
float maximum)
Clamp the elements of the vector
v to the range
[-Infinity .. |
static VectorI3F |
clampMaximumByVector(VectorReadable3FType v,
VectorReadable3FType maximum)
Clamp the elements of the vector
v to the inclusive range
given by the corresponding elements in maximum. |
static VectorI3F |
clampMinimum(VectorReadable3FType v,
float minimum)
Clamp the elements of the vector
v to the range
[minimum .. |
static VectorI3F |
clampMinimumByVector(VectorReadable3FType v,
VectorReadable3FType minimum)
Clamp the elements of the vector
v to the inclusive range
given by the corresponding elements in minimum. |
static VectorI3F |
crossProduct(VectorReadable3FType v0,
VectorReadable3FType v1)
Calculate the cross product of the vectors
v0 and
v1. |
static float |
distance(VectorReadable3FType v0,
VectorReadable3FType v1)
Calculate the distance between the two vectors
v0 and
v1. |
static float |
dotProduct(VectorReadable3FType v0,
VectorReadable3FType v1)
Calculate the scalar product of the vectors
v0 and
v1. |
boolean |
equals(Object obj) |
float |
getXF() |
float |
getYF() |
float |
getZF() |
int |
hashCode() |
static VectorI3F |
interpolateLinear(VectorReadable3FType v0,
VectorReadable3FType v1,
float alpha)
Linearly interpolate between
v0 and v1 by the
amount alpha. |
static float |
magnitude(VectorReadable3FType v)
Calculate the magnitude of the vector
v. |
static float |
magnitudeSquared(VectorReadable3FType v)
Calculate the squared magnitude of the vector
v. |
static VectorI3F |
normalize(VectorReadable3FType v)
Normalize the vector
v, preserving its direction but
reducing it to unit length. |
static com.io7m.jfunctional.Pair<VectorI3F,VectorI3F> |
orthoNormalize(VectorReadable3FType v0,
VectorReadable3FType v1)
Orthonormalize and return the vectors
v0 and v1
. |
static VectorI3F |
projection(VectorReadable3FType p,
VectorReadable3FType q)
Calculate the projection of the vector
p onto the vector
q. |
static VectorI3F |
scale(VectorReadable3FType v,
float r)
Scale the vector
v by the scalar r. |
static VectorI3F |
subtract(VectorReadable3FType v0,
VectorReadable3FType v1)
Subtract the vector
v1 from the vector v0. |
String |
toString() |
public static final VectorI3F ZERO
public VectorI3F()
[0.0, 0.0, 0.0].public VectorI3F(float in_x,
float in_y,
float in_z)
in_x - The x valuein_y - The y valuein_z - The z valuepublic VectorI3F(VectorReadable3FType in_v)
in_v.in_v - The input vector.public static final VectorI3F absolute(VectorReadable3FType v)
v.v - The input vector(abs v.getXF(), abs v.getYF(), abs v.getZF())public static final VectorI3F add(VectorReadable3FType v0, VectorReadable3FType 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())public static final VectorI3F addScaled(VectorReadable3FType v0, VectorReadable3FType 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))public static final boolean almostEqual(com.io7m.jequality.AlmostEqualFloat.ContextRelative context,
VectorReadable3FType va,
VectorReadable3FType 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 VectorI3F clamp(VectorReadable3FType 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 minimum.public static final VectorI3F clampByVector(VectorReadable3FType v, VectorReadable3FType minimum, VectorReadable3FType 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())
)public static final VectorI3F clampMaximum(VectorReadable3FType v, float maximum)
v to the range
[-Infinity .. maximum] inclusive.v - The input vectormaximum - The maximum allowed valuemaximumpublic static final VectorI3F clampMaximumByVector(VectorReadable3FType v, VectorReadable3FType 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()))public static final VectorI3F clampMinimum(VectorReadable3FType v, float minimum)
v to the range
[minimum .. Infinity] inclusive.v - The input vectorminimum - The minimum allowed valueminimumpublic static final VectorI3F clampMinimumByVector(VectorReadable3FType v, VectorReadable3FType 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()))public static final VectorI3F crossProduct(VectorReadable3FType v0, VectorReadable3FType v1)
v0 and
v1. The result is a vector perpendicular to both vectors.v0 - The left input vectorv1 - The right input vectorv0 and
v1public static final float distance(VectorReadable3FType v0, VectorReadable3FType v1)
v0 and
v1.v0 - The left input vectorv1 - The right input vectorpublic static final float dotProduct(VectorReadable3FType v0, VectorReadable3FType v1)
v0 and
v1.v0 - The left input vectorv1 - The right input vectorpublic static final VectorI3F interpolateLinear(VectorReadable3FType v0, VectorReadable3FType 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(VectorReadable3FType v)
v.
Correspondingly, magnitude(normalize(v)) == 1.0.v - The input vectorpublic static final float magnitudeSquared(VectorReadable3FType v)
v.v - The input vectorpublic static final VectorI3F normalize(VectorReadable3FType 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<VectorI3F,VectorI3F> orthoNormalize(VectorReadable3FType v0, VectorReadable3FType v1)
Orthonormalize and return the vectors v0 and v1
.
See GSP
v0 - The left vectorv1 - The right vector(v0, v1), orthonormalized.public static final VectorI3F projection(VectorReadable3FType p, VectorReadable3FType q)
p onto the vector
q.p - The left vectorq - The right vector((dotProduct p q) / magnitudeSquared q) * qpublic static final VectorI3F scale(VectorReadable3FType v, float r)
v by the scalar r.v - The input vectorr - The scaling value(v.getXF() * r, v.getYF() * r, v.getZF() * r)public static final VectorI3F subtract(VectorReadable3FType v0, VectorReadable3FType 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 getXF()
getXF in interface VectorReadable2FTypepublic final float getYF()
getYF in interface VectorReadable2FTypepublic final float getZF()
getZF in interface VectorReadable3FTypeCopyright © 2015 <code@io7m.com> http://io7m.com