public class VectorM3F extends Object implements VectorReadable3FType, VectorWritable3FType
A three-dimensional mutable vector type with single precision elements.
Values of this type cannot be accessed safely from multiple threads without explicit synchronization.
| Constructor and Description |
|---|
VectorM3F()
Default constructor, initializing the vector with values
[0.0, 0.0, 0.0]. |
VectorM3F(float in_x,
float in_y,
float in_z)
Construct a vector initialized with the given values.
|
VectorM3F(VectorReadable3FType in_v)
Construct a vector initialized with the values given in the vector
in_v. |
| Modifier and Type | Method and Description |
|---|---|
static VectorM3F |
absolute(VectorReadable3FType v,
VectorM3F out)
Calculate the absolute values of the elements in vector
v,
saving the result to out. |
static VectorM3F |
absoluteInPlace(VectorM3F v)
Calculate the absolute values of the elements in vector
v,
modifying the vector in-place. |
static VectorM3F |
add(VectorReadable3FType v0,
VectorReadable3FType v1,
VectorM3F out)
Calculate the element-wise sum of the vectors
v0 and
v1, saving the result to out. |
static VectorM3F |
addInPlace(VectorM3F v0,
VectorReadable3FType v1)
Calculate the element-wise sum of the vectors
v0 and
v1, saving the result to v0. |
static VectorM3F |
addScaled(VectorReadable3FType v0,
VectorReadable3FType v1,
double r,
VectorM3F 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 VectorM3F |
addScaledInPlace(VectorM3F v0,
VectorReadable3FType 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 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 VectorM3F |
clamp(VectorReadable3FType v,
float minimum,
float maximum,
VectorM3F out)
Clamp the elements of the vector
v to the range
[minimum .. |
static VectorM3F |
clampByVector(VectorReadable3FType v,
VectorReadable3FType minimum,
VectorReadable3FType maximum,
VectorM3F 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 VectorM3F |
clampByVectorInPlace(VectorM3F 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, saving the result to v. |
static VectorM3F |
clampInPlace(VectorM3F v,
float minimum,
float maximum)
Clamp the elements of the vector
v to the range
[minimum .. |
static VectorM3F |
clampMaximum(VectorReadable3FType v,
float maximum,
VectorM3F out)
Clamp the elements of the vector
v to the range
[-Infinity .. |
static VectorM3F |
clampMaximumByVector(VectorReadable3FType v,
VectorReadable3FType maximum,
VectorM3F 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 VectorM3F |
clampMaximumByVectorInPlace(VectorM3F v,
VectorReadable3FType 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 VectorM3F |
clampMaximumInPlace(VectorM3F v,
float maximum)
Clamp the elements of the vector
v to the range
[-Infinity .. |
static VectorM3F |
clampMinimum(VectorReadable3FType v,
float minimum,
VectorM3F out)
Clamp the elements of the vector
v to the range
[minimum .. |
static VectorM3F |
clampMinimumByVector(VectorReadable3FType v,
VectorReadable3FType minimum,
VectorM3F 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 VectorM3F |
clampMinimumByVectorInPlace(VectorM3F v,
VectorReadable3FType 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 VectorM3F |
clampMinimumInPlace(VectorM3F v,
float minimum)
Clamp the elements of the vector
v to the range
[minimum .. |
static <T extends VectorWritable3FType> |
copy(VectorReadable3FType input,
T output)
Copy all elements of the vector
input to the vector
output. |
void |
copyFrom2F(VectorReadable2FType in_v)
Set the current vector to the contents of the input vector.
|
void |
copyFrom3F(VectorReadable3FType in_v)
Set the current vector to the contents of the input vector.
|
static VectorM3F |
crossProduct(VectorReadable3FType v0,
VectorReadable3FType v1,
VectorM3F out)
Return a vector perpendicular to both
v0 and v1
, saving the result in out. |
static double |
distance(VectorReadable3FType v0,
VectorReadable3FType v1)
Calculate the distance between the two vectors
v0 and
v1. |
static double |
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 VectorM3F |
interpolateLinear(VectorReadable3FType v0,
VectorReadable3FType v1,
double alpha,
VectorM3F r)
Linearly interpolate between
v0 and v1 by the
amount alpha, saving the result to r. |
static float |
magnitude(VectorReadable3FType v)
Calculate the magnitude of the vector
v. |
static double |
magnitudeSquared(VectorReadable3FType v)
Calculate the squared magnitude of the vector
v. |
static VectorM3F |
normalize(VectorReadable3FType v,
VectorM3F out)
Returns a vector with the same orientation as
v but with
magnitude equal to 1.0 in out. |
static VectorM3F |
normalizeInPlace(VectorM3F v)
Returns a vector with the same orientation as
v but with
magnitude equal to 1.0 in v. |
static com.io7m.jfunctional.Pair<VectorM3F,VectorM3F> |
orthoNormalize(VectorReadable3FType v0,
VectorReadable3FType v1)
Orthonormalize and return the vectors
v0 and v1
. |
static void |
orthoNormalizeInPlace(VectorM3F v0,
VectorM3F v1)
Orthonormalize and the vectors
v0 and v1. |
static VectorM3F |
projection(VectorReadable3FType p,
VectorReadable3FType q,
VectorM3F r)
Calculate the projection of the vector
p onto the vector
q, saving the result in r. |
static VectorM3F |
scale(VectorReadable3FType v,
double r,
VectorM3F out)
Scale the vector
v by the scalar r, saving the
result to out. |
static VectorM3F |
scaleInPlace(VectorM3F v,
double r)
Scale the vector
v by the scalar r, saving the
result to v. |
void |
set2F(float in_x,
float in_y)
Set the current
x and y values of the current
vector. |
void |
set3F(float in_x,
float in_y,
float in_z)
Set the current
x, y and z values
of the current vector. |
void |
setXF(float in_x)
Set the current
x value of the current vector. |
void |
setYF(float in_y)
Set the current
y value of the current vector. |
void |
setZF(float in_z)
Set the current
z value of the current vector. |
static VectorM3F |
subtract(VectorReadable3FType v0,
VectorReadable3FType v1,
VectorM3F out)
Subtract the vector
v1 from the vector v0,
saving the result to out. |
static VectorM3F |
subtractInPlace(VectorM3F v0,
VectorReadable3FType v1)
Subtract the vector
v1 from the vector v0,
saving the result to v0. |
String |
toString() |
public VectorM3F()
[0.0, 0.0, 0.0].public VectorM3F(float in_x,
float in_y,
float in_z)
in_x - The x valuein_y - The y valuein_z - The z valuepublic VectorM3F(VectorReadable3FType in_v)
in_v.in_v - The source vectorpublic static final VectorM3F absolute(VectorReadable3FType v, VectorM3F out)
v,
saving the result to out.v - The input vectorout - The output vector(abs v.x, abs v.y, abs v.z)public static final VectorM3F absoluteInPlace(VectorM3F v)
v,
modifying the vector in-place.v - The input vector(abs v.x, abs v.y, abs v.z)public static final VectorM3F add(VectorReadable3FType v0, VectorReadable3FType v1, VectorM3F out)
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)public static final VectorM3F addInPlace(VectorM3F v0, VectorReadable3FType v1)
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)public static final VectorM3F addScaled(VectorReadable3FType v0, VectorReadable3FType v1, double r, VectorM3F out)
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))public static final VectorM3F addScaledInPlace(VectorM3F v0, VectorReadable3FType v1, double r)
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))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 if the vectors are almost equalAlmostEqualFloat.almostEqual(ContextRelative, float, float)public static final VectorM3F clamp(VectorReadable3FType v, float minimum, float maximum, VectorM3F 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 VectorM3F clampByVector(VectorReadable3FType v, VectorReadable3FType minimum, VectorReadable3FType maximum, VectorM3F 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))public static final VectorM3F clampByVectorInPlace(VectorM3F v, VectorReadable3FType minimum, VectorReadable3FType 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))public static final VectorM3F clampInPlace(VectorM3F v, float minimum, float 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 VectorM3F clampMaximum(VectorReadable3FType v, float maximum, VectorM3F 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 VectorM3F clampMaximumByVector(VectorReadable3FType v, VectorReadable3FType maximum, VectorM3F 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))public static final VectorM3F clampMaximumByVectorInPlace(VectorM3F v, VectorReadable3FType 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))public static final VectorM3F clampMaximumInPlace(VectorM3F v, float 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 VectorM3F clampMinimum(VectorReadable3FType v, float minimum, VectorM3F 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 VectorM3F clampMinimumByVector(VectorReadable3FType v, VectorReadable3FType minimum, VectorM3F 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))public static final VectorM3F clampMinimumByVectorInPlace(VectorM3F v, VectorReadable3FType 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))
, in vpublic static final VectorM3F clampMinimumInPlace(VectorM3F v, float 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 VectorWritable3FType> T copy(VectorReadable3FType input, T output)
input to the vector
output.T - The specific type of vectorinput - The input vectoroutput - The output vectorpublic static final VectorM3F crossProduct(VectorReadable3FType v0, VectorReadable3FType v1, VectorM3F out)
v0 and v1
, saving the result in out.v0 - The left input vector.v1 - The right input vector.out - The output vector.public static final double distance(VectorReadable3FType v0, VectorReadable3FType v1)
v0 and
v1.v0 - The left input vectorv1 - The right input vectorpublic static final double dotProduct(VectorReadable3FType v0, VectorReadable3FType v1)
v0 and
v1.v0 - The left input vectorv1 - The right input vectorpublic static final VectorM3F interpolateLinear(VectorReadable3FType v0, VectorReadable3FType v1, double alpha, VectorM3F r)
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.rpublic static final float magnitude(VectorReadable3FType v)
v.
Correspondingly, magnitude(normalize(v)) == 1.0.v - The input vectorpublic static final double magnitudeSquared(VectorReadable3FType v)
v.v - The input vectorpublic static final VectorM3F normalize(VectorReadable3FType v, VectorM3F out)
v but with
magnitude equal to 1.0 in out. The function
returns the zero vector iff the input is the zero vector.v - The input vectorout - The output vectorpublic static final VectorM3F normalizeInPlace(VectorM3F v)
v but with
magnitude equal to 1.0 in v. The function
returns the zero vector iff the input is the zero vector.v - The input vectorpublic static final com.io7m.jfunctional.Pair<VectorM3F,VectorM3F> 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 void orthoNormalizeInPlace(VectorM3F v0, VectorM3F v1)
Orthonormalize and the vectors v0 and v1.
See GSP
v0 - The left vectorv1 - The right vectorpublic static final VectorM3F projection(VectorReadable3FType p, VectorReadable3FType q, VectorM3F r)
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) * qpublic static final VectorM3F scale(VectorReadable3FType v, double r, VectorM3F out)
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)public static final VectorM3F scaleInPlace(VectorM3F v, double r)
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)public static final VectorM3F subtract(VectorReadable3FType v0, VectorReadable3FType v1, VectorM3F out)
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)public static final VectorM3F subtractInPlace(VectorM3F v0, VectorReadable3FType v1)
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)public final void copyFrom2F(VectorReadable2FType in_v)
VectorWritable2FTypecopyFrom2F in interface VectorWritable2FTypein_v - The input vectorpublic final void copyFrom3F(VectorReadable3FType in_v)
VectorWritable3FTypecopyFrom3F in interface VectorWritable3FTypein_v - The input vectorpublic final float getXF()
getXF in interface VectorReadable2FTypepublic final float getYF()
getYF in interface VectorReadable2FTypepublic final float getZF()
getZF in interface VectorReadable3FTypepublic final void set2F(float in_x,
float in_y)
VectorWritable2FTypex and y values of the current
vector.set2F in interface VectorWritable2FTypein_x - The new x value.in_y - The new y value.public final void set3F(float in_x,
float in_y,
float in_z)
VectorWritable3FTypex, y and z values
of the current vector.set3F in interface VectorWritable3FTypein_x - The new x value.in_y - The new y value.in_z - The new z value.public final void setXF(float in_x)
VectorWritable2FTypex value of the current vector.setXF in interface VectorWritable2FTypein_x - The new x value.public final void setYF(float in_y)
VectorWritable2FTypey value of the current vector.setYF in interface VectorWritable2FTypein_y - The new y value.public final void setZF(float in_z)
VectorWritable3FTypez value of the current vector.setZF in interface VectorWritable3FTypein_z - The new z value.Copyright © 2015 <code@io7m.com> http://io7m.com