T - A phantom type parameter.@Immutable public final class PVectorI3D<T> extends Object implements PVectorReadable3DType<T>
A three-dimensional immutable vector type with double elements.
Values of this type are immutable and can therefore be safely accessed from multiple threads.
| Modifier and Type | Field and Description |
|---|---|
static PVectorI3D<?> |
ZERO
The zero vector.
|
| Constructor and Description |
|---|
PVectorI3D()
Default constructor, initializing the vector with values
[0.0, 0.0,
0.0]. |
PVectorI3D(double in_x,
double in_y,
double in_z)
Construct a vector initialized with the given values.
|
PVectorI3D(PVectorReadable3DType<T> in_v)
Construct a vector initialized with the values given in the vector
in_v. |
| Modifier and Type | Method and Description |
|---|---|
static <T> PVectorI3D<T> |
absolute(PVectorReadable3DType<T> v)
Calculate the absolute value of the vector
v. |
static <T> PVectorI3D<T> |
add(PVectorReadable3DType<T> v0,
PVectorReadable3DType<T> v1)
Calculate the element-wise sum of the vectors
v0 and v1. |
static <T> PVectorI3D<T> |
addScaled(PVectorReadable3DType<T> v0,
PVectorReadable3DType<T> v1,
double r)
Calculate the element-wise sum of the vectors
v0 and the
element-wise product of v1 and r. |
static <T> boolean |
almostEqual(com.io7m.jequality.AlmostEqualDouble.ContextRelative context,
PVectorReadable3DType<T> qa,
PVectorReadable3DType<T> qb)
Determine whether or not the vectors
qa and qb are equal to
within the degree of error given in context. |
static <T> PVectorI3D<T> |
clamp(PVectorReadable3DType<T> v,
double minimum,
double maximum)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <T> PVectorI3D<T> |
clampByPVector(PVectorReadable3DType<T> v,
PVectorReadable3DType<T> minimum,
PVectorReadable3DType<T> maximum)
Clamp the elements of the vector
v to the inclusive range given by
the corresponding elements in minimum and maximum. |
static <T> PVectorI3D<T> |
clampMaximum(PVectorReadable3DType<T> v,
double maximum)
Clamp the elements of the vector
v to the range {@code [-Infinity
.. |
static <T> PVectorI3D<T> |
clampMaximumByPVector(PVectorReadable3DType<T> v,
PVectorReadable3DType<T> maximum)
Clamp the elements of the vector
v to the inclusive range given by
the corresponding elements in maximum. |
static <T> PVectorI3D<T> |
clampMinimum(PVectorReadable3DType<T> v,
double minimum)
Clamp the elements of the vector
v to the range {@code [minimum .. |
static <T> PVectorI3D<T> |
clampMinimumByPVector(PVectorReadable3DType<T> v,
PVectorReadable3DType<T> minimum)
Clamp the elements of the vector
v to the inclusive range given by
the corresponding elements in minimum. |
static <T> PVectorI3D<T> |
crossProduct(PVectorReadable3DType<T> v0,
PVectorReadable3DType<T> v1)
Calculate the cross product of the vectors
v0 and v1. |
static <T> double |
distance(PVectorReadable3DType<T> v0,
PVectorReadable3DType<T> v1)
Calculate the distance between the two vectors
v0 and v1. |
static <T> double |
dotProduct(PVectorReadable3DType<T> v0,
PVectorReadable3DType<T> v1)
Calculate the scalar product of the vectors
v0 and v1. |
boolean |
equals(Object obj) |
double |
getXD() |
double |
getYD() |
double |
getZD() |
int |
hashCode() |
static <T> PVectorI3D<T> |
interpolateLinear(PVectorReadable3DType<T> v0,
PVectorReadable3DType<T> v1,
double alpha)
Linearly interpolate between
v0 and v1 by the amount alpha. |
static <T> double |
magnitude(PVectorReadable3DType<T> v)
Calculate the magnitude of the vector
v. |
static <T> double |
magnitudeSquared(PVectorReadable3DType<T> v)
Calculate the squared magnitude of the vector
v. |
static <T> PVectorI3D<T> |
normalize(PVectorReadable3DType<T> v)
Normalize the vector
v, preserving its direction but reducing it to
unit length. |
static <T> com.io7m.jfunctional.Pair<PVectorI3D<T>,PVectorI3D<T>> |
orthoNormalize(PVectorReadable3DType<T> v0,
PVectorReadable3DType<T> v1)
Orthonormalize and return the vectors
v0 and v1 . |
static <T> PVectorI3D<T> |
projection(PVectorReadable3DType<T> p,
PVectorReadable3DType<T> q)
Calculate the projection of the vector
p onto the vector q. |
static <T> PVectorI3D<T> |
scale(PVectorReadable3DType<T> v,
double r)
Scale the vector
v by the scalar r. |
static <T> PVectorI3D<T> |
subtract(PVectorReadable3DType<T> v0,
PVectorReadable3DType<T> v1)
Subtract the vector
v1 from the vector v0. |
String |
toString() |
static <T> PVectorI3D<T> |
zero() |
public static final PVectorI3D<?> ZERO
public PVectorI3D()
[0.0, 0.0,
0.0].public PVectorI3D(double in_x,
double in_y,
double in_z)
in_x - The x valuein_y - The y valuein_z - The z valuepublic PVectorI3D(PVectorReadable3DType<T> in_v)
in_v.in_v - The input vector.public static <T> PVectorI3D<T> absolute(PVectorReadable3DType<T> v)
v.T - A phantom type parameter.v - The input vector(abs v.x, abs v.y, abs v.z)public static <T> PVectorI3D<T> add(PVectorReadable3DType<T> v0, PVectorReadable3DType<T> v1)
v0 and v1.T - A phantom type parameter.v0 - The left input vectorv1 - The right input vector(v0.x + v1.x, v0.y + v1.y, v0.z + v1.z)public static <T> PVectorI3D<T> addScaled(PVectorReadable3DType<T> v0, PVectorReadable3DType<T> v1, double r)
v0 and the
element-wise product of v1 and r.T - A phantom type parameter.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 <T> boolean almostEqual(com.io7m.jequality.AlmostEqualDouble.ContextRelative context,
PVectorReadable3DType<T> qa,
PVectorReadable3DType<T> qb)
qa and qb are equal to
within the degree of error given in context.T - A phantom type parameter.context - The equality contextqa - The left input vectorqb - The right input vectortrue iff the vectors are almost equal.AlmostEqualDouble.almostEqual(ContextRelative, double, double)public static <T> PVectorI3D<T> clamp(PVectorReadable3DType<T> v, double minimum, double maximum)
v to the range [minimum ..
maximum] inclusive.T - A phantom type parameter.v - The input vectorminimum - The minimum allowed valuemaximum - The maximum allowed valuemaximum and at
least minimum.public static <T> PVectorI3D<T> clampByPVector(PVectorReadable3DType<T> v, PVectorReadable3DType<T> minimum, PVectorReadable3DType<T> maximum)
v to the inclusive range given by
the corresponding elements in minimum and maximum.T - A phantom type parameter.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 <T> PVectorI3D<T> clampMaximum(PVectorReadable3DType<T> v, double maximum)
v to the range [-Infinity
.. maximum] inclusive.T - A phantom type parameter.v - The input vectormaximum - The maximum allowed valuemaximumpublic static <T> PVectorI3D<T> clampMaximumByPVector(PVectorReadable3DType<T> v, PVectorReadable3DType<T> maximum)
v to the inclusive range given by
the corresponding elements in maximum.T - A phantom type parameter.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 <T> PVectorI3D<T> clampMinimum(PVectorReadable3DType<T> v, double minimum)
v to the range [minimum ..
Infinity] inclusive.T - A phantom type parameter.v - The input vectorminimum - The minimum allowed valueminimumpublic static <T> PVectorI3D<T> clampMinimumByPVector(PVectorReadable3DType<T> v, PVectorReadable3DType<T> minimum)
v to the inclusive range given by
the corresponding elements in minimum.T - A phantom type parameter.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))public static <T> PVectorI3D<T> crossProduct(PVectorReadable3DType<T> v0, PVectorReadable3DType<T> v1)
v0 and v1. The
result is a vector perpendicular to both vectors.T - A phantom type parameter.v0 - The left input vectorv1 - The right input vectorv0 and v1public static <T> double distance(PVectorReadable3DType<T> v0, PVectorReadable3DType<T> v1)
v0 and v1.T - A phantom type parameter.v0 - The left input vectorv1 - The right input vectorpublic static <T> double dotProduct(PVectorReadable3DType<T> v0, PVectorReadable3DType<T> v1)
v0 and v1.T - A phantom type parameter.v0 - The left input vectorv1 - The right input vectorpublic static <T> PVectorI3D<T> interpolateLinear(PVectorReadable3DType<T> v0, PVectorReadable3DType<T> v1, double 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) = v1T - A phantom type parameter.v0 - 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 <T> double magnitude(PVectorReadable3DType<T> v)
v.
Correspondingly, magnitude(normalize(v)) == 1.0.T - A phantom type parameter.v - The input vectorpublic static <T> double magnitudeSquared(PVectorReadable3DType<T> v)
v.T - A phantom type parameter.v - The input vectorpublic static <T> PVectorI3D<T> normalize(PVectorReadable3DType<T> v)
v, preserving its direction but reducing it to
unit length.T - A phantom type parameter.v - The input vectorv but with magnitude
equal to 1.0public static <T> com.io7m.jfunctional.Pair<PVectorI3D<T>,PVectorI3D<T>> orthoNormalize(PVectorReadable3DType<T> v0, PVectorReadable3DType<T> v1)
Orthonormalize and return the vectors v0 and v1 .
See GSP
T - A phantom type parameter.v0 - The left vectorv1 - The right vector(v0, v1), orthonormalized.public static <T> PVectorI3D<T> projection(PVectorReadable3DType<T> p, PVectorReadable3DType<T> q)
p onto the vector q.T - A phantom type parameter.p - The left vectorq - The right vector((dotProduct p q) / magnitudeSquared q) * qpublic static <T> PVectorI3D<T> scale(PVectorReadable3DType<T> v, double r)
v by the scalar r.T - A phantom type parameter.v - The input vectorr - The scaling value(v.x * r, v.y * r, v.z * r)public static <T> PVectorI3D<T> subtract(PVectorReadable3DType<T> v0, PVectorReadable3DType<T> v1)
v1 from the vector v0.T - A phantom type parameter.v0 - The left input vectorv1 - The right input vector(v0.x - v1.x, v0.y - v1.y, v0.z - v1.z)public static <T> PVectorI3D<T> zero()
T - A phantom type parameter.public double getXD()
getXD in interface VectorReadable2DTypepublic double getYD()
getYD in interface VectorReadable2DTypepublic double getZD()
getZD in interface VectorReadable3DTypeCopyright © 2015 <code@io7m.com> http://io7m.com