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