public class Vector4d extends VectorBase implements Clonable, VectorObject<Vector4d>
The size of these vectors is fixed.
Modifier and Type | Field and Description |
---|---|
static Vector4d |
ONES
Global vector containing ones.
|
double |
w
Fourth element
|
static Vector4d |
W_UNIT
Global unit vector along the w axis.
|
double |
x
First element
|
static Vector4d |
X_UNIT
Global unit vector along the x axis.
|
double |
y
Second element
|
static Vector4d |
Y_UNIT
Global unit vector along the y axis.
|
double |
z
Third element
|
static Vector4d |
Z_UNIT
Global unit vector along the z axis.
|
static Vector4d |
ZERO
Global zero vector.
|
Constructor and Description |
---|
Vector4d()
Creates a 4-vector and initializes its elements to 0.
|
Vector4d(double x,
double y,
double z,
double w)
Creates a 4-vector with the supplied element values.
|
Vector4d(Vector4d v)
Creates a 4-vector by copying an existing one.
|
Modifier and Type | Method and Description |
---|---|
Vector4d |
absolute()
Sets the elements of this vector to their absolute values.
|
Vector4d |
absolute(Vector4d v1)
Sets the elements of this vector to the absolute value of v1.
|
Vector4d |
add(double dx,
double dy,
double dz,
double dw)
Adds specified increments to the components of this vector.
|
Vector4d |
add(Vector4d v1)
Adds this vector to v1 and places the result in this vector.
|
Vector4d |
add(Vector4d v1,
Vector4d v2)
Adds vector v1 to v2 and places the result in this vector.
|
void |
addObj(Vector4d v1)
Adds
v1 to this vector. |
double |
angle(Vector4d v1)
Returns the angle between this vector and v1.
|
Vector4d |
clone() |
Vector4d |
combine(double s1,
Vector4d v1,
double s2,
Vector4d v2)
Computes
s1 v1 + s2 v2 and places the result in this
vector. |
double |
distance(Vector4d v)
Returns the Euclidean distance between this vector and vector v.
|
double |
distanceSquared(Vector4d v)
Returns the squared of the Euclidean distance between this vector and
vector v.
|
double |
dot(Vector4d v1)
Returns the dot product of this vector and v1.
|
boolean |
epsilonEquals(Vector4d v1,
double eps)
Returns true if the elements of this vector equal those of vector
v1 within a prescribed tolerance epsilon . |
boolean |
equals(Vector4d v1)
Returns true if the elements of this vector exactly equal those of vector
v1 . |
void |
get(double[] values)
Copies the elements of this vector into an array of doubles.
|
double |
get(int i)
Gets a single element of this vector.
|
void |
get(Vector3d v)
Gets the first three values of this vector.
|
void |
get(VectorNd v1,
int idx)
Copies the values of this vector into a general length vector v1, starting
at a specified index.
|
double |
infinityNorm()
Returns the infinity norm of this vector.
|
void |
interpolate(double s,
Vector4d v1)
Computes the interpolation
(1-s) this + s v1 and places the
result in this vector. |
void |
interpolate(Vector4d v1,
double s,
Vector4d v2)
Computes the interpolation
(1-s) v1 + s v2 and places the
result in this vector. |
void |
inverseTransform(RigidTransform3d X) |
void |
inverseTransform(RigidTransform3d X,
Vector4d v1) |
void |
inverseTransform(RotationMatrix3d R) |
void |
inverseTransform(RotationMatrix3d R,
Vector4d v1) |
double |
length()
Returns the 2 norm of this vector.
|
double |
lengthSquared()
Returns the square of the 2 norm of this vector.
|
Vector4d |
max(Vector4d v)
Computes the element-wise maximum of this vector and vector v and places
the result in this vector.
|
int |
maxAbsIndex()
Returns the index (0, 1, 2, or 3) of the element of v with the largest
absolute value.
|
double |
maxElement()
Returns the maximum element value of this vector.
|
Vector4d |
min(Vector4d v)
Computes the element-wise minimum of this vector and vector v and places
the result in this vector.
|
int |
minAbsIndex()
Returns the index (0, 1, 2, or 3) of the element of v with the smallest
absolute value.
|
double |
minElement()
Returns the minimum element value of this vector.
|
Vector4d |
mul(Matrix4dBase X,
Vector4d v1)
Multiplies matrix X by vector v1 and places the result in this vector.
|
Vector4d |
negate()
Negates this vector in place.
|
Vector4d |
negate(Vector4d v1)
Sets this vector to the negative of v1.
|
Vector4d |
normalize()
Normalizes this vector in place.
|
Vector4d |
normalize(Vector4d v1)
Computes a unit vector in the direction of v1 and places the result in
this vector.
|
double |
oneNorm()
Returns the 1 norm of this vector.
|
Vector4d |
scale(double s)
Scales the elements of this vector by
s . |
Vector4d |
scale(double s,
Vector4d v1)
Scales the elements of vector v1 by
s and places the
results in this vector. |
Vector4d |
scaledAdd(double s,
Vector4d v1)
Computes
s v1 and adds the result to this vector. |
Vector4d |
scaledAdd(double s,
Vector4d v1,
Vector4d v2)
Computes
s v1 + v2 and places the result in this vector. |
void |
scaledAddObj(double s,
Vector4d v1)
Scales
v1 by s and adds it to this vector. |
void |
scaleObj(double s)
Scales this vector by
s . |
void |
set(double[] values)
Sets the elements of this vector from an array of doubles.
|
int |
set(double[] values,
int idx)
Sets the elements of this vector from an array of doubles,
starting from a particular location.
|
void |
set(double x,
double y,
double z,
double w)
Sets the elements of this vector to the prescribed values.
|
void |
set(int i,
double value)
Sets a single element of this vector.
|
void |
set(Vector3d v,
double w)
Sets the elements of this vector to the prescribed values.
|
void |
set(Vector4d v1)
Sets the values of this vector to those of v1.
|
void |
set(VectorNd v1,
int idx)
Sets the values of this vector from the elements of a general length
vector v1, starting at a specified index.
|
void |
setRandom()
Sets the elements of this vector to uniformly distributed random values in
the range -0.5 (inclusive) to 0.5 (exclusive).
|
void |
setRandom(double lower,
double upper)
Sets the elements of this vector to uniformly distributed random values in
a specified range.
|
void |
setRandom(double lower,
double upper,
java.util.Random generator)
Sets the elements of this vector to uniformly distributed random values in
a specified range, using a supplied random number generator.
|
void |
setToHomogeneous(Vector3d v1,
double w)
Sets the values of this vector to a homogeneous representation formed from
a 3-vector and a weighting factor w.
|
void |
setZero()
Sets the elements of this vector to zero.
|
int |
size()
Returns the size of this vector (which is always 4)
|
void |
sort()
Sorts the contents of this vector by element value, with x being set to
the largest value and w being set to the smallest value.
|
void |
sort(Vector4d v1)
Sorts the contents of vector v1 by element value, with x being set to the
largest value and w being set to the smallest value, and places the
results in this vector.
|
void |
sortAbsolute()
Sorts the contents of the vector by the absolute value of its components.
|
Vector4d |
sub(Vector4d v1)
Subtracts v1 from this vector and places the result in this vector.
|
Vector4d |
sub(Vector4d v1,
Vector4d v2)
Subtracts vector v1 from v2 and places the result in this vector.
|
void |
transform(AffineTransform3dBase X) |
void |
transform(AffineTransform3dBase X,
Vector4d v1) |
void |
transform(RotationMatrix3d R) |
void |
transform(RotationMatrix3d R,
Vector4d v1) |
void |
updateBounds(Vector4d vmin,
Vector4d vmax)
Updates a bounding box to include this vector.
|
containsNaN, copy, copyAndAdd, copyAndNegate, copyAndScale, copyAndSub, copyAndSubLeft, dot, epsilonEquals, equals, get, getDefaultFormat, hasInf, hasNaN, isColumnVectorStringsVertical, isFixedSize, isRowVector, isWritable, norm, normSquared, scan, scan, set, set, setColumnVectorStringsVertical, setDefaultFormat, setRowVector, setSize, toString, toString, toString, write, write, write, writeToFile
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getThreeVectorValue
isWritable, scan, write
public static final Vector4d ZERO
public static final Vector4d X_UNIT
public static final Vector4d Y_UNIT
public static final Vector4d Z_UNIT
public static final Vector4d W_UNIT
public static final Vector4d ONES
public double x
public double y
public double z
public double w
public Vector4d()
public Vector4d(Vector4d v)
v
- vector to be copiedpublic Vector4d(double x, double y, double z, double w)
x
- first elementy
- second elementz
- third elementw
- fourth elementpublic int size()
size
in interface Vector
size
in class VectorBase
public void get(Vector3d v)
v
- returns the first three valuespublic double get(int i)
get
in interface Vector
get
in class VectorBase
i
- element indexpublic void get(double[] values)
>=
the size of the vector.get
in interface Vector
get
in class VectorBase
values
- array into which values are copiedpublic void get(VectorNd v1, int idx)
v1
- vector into which values are to be copiedidx
- starting index for copying valuesjava.lang.ArrayIndexOutOfBoundsException
- if idx specifies a region within v1 that exceeds its boundspublic void set(int i, double value)
set
in interface Vector
set
in class VectorBase
i
- element indexvalue
- element valuejava.lang.ArrayIndexOutOfBoundsException
- if i is not in the range 0 to 3.public void set(double[] values)
set
in interface Vector
set
in class VectorBase
values
- array from which values are copiedpublic int set(double[] values, int idx)
public void set(Vector4d v1)
set
in interface VectorObject<Vector4d>
v1
- vector whose values are copiedpublic void set(VectorNd v1, int idx)
v1
- vector from which new values are copiedidx
- starting index for new valuesjava.lang.ArrayIndexOutOfBoundsException
- if idx specifies a region within v1 that exceeds its boundspublic Vector4d add(Vector4d v1, Vector4d v2)
v1
- left-hand vectorv2
- right-hand vectorpublic Vector4d add(Vector4d v1)
v1
- right-hand vectorpublic Vector4d add(double dx, double dy, double dz, double dw)
dx
- x incrementdy
- y incrementdz
- z incrementdw
- w incrementpublic Vector4d sub(Vector4d v1, Vector4d v2)
v1
- left-hand vectorv2
- right-hand vectorpublic Vector4d sub(Vector4d v1)
v1
- right-hand vectorpublic Vector4d negate(Vector4d v1)
v1
- vector to negatepublic Vector4d negate()
public Vector4d scale(double s)
s
.s
- scaling factorpublic Vector4d scale(double s, Vector4d v1)
s
and places the
results in this vector.s
- scaling factorv1
- vector to be scaledpublic void interpolate(Vector4d v1, double s, Vector4d v2)
(1-s) v1 + s v2
and places the
result in this vector.v1
- left-hand vectors
- interpolation factorv2
- right-hand vectorpublic void interpolate(double s, Vector4d v1)
(1-s) this + s v1
and places the
result in this vector.s
- interpolation factorv1
- right-hand vectorpublic Vector4d scaledAdd(double s, Vector4d v1)
s v1
and adds the result to this vector.s
- scaling factorv1
- vector to be scaled and addedpublic Vector4d scaledAdd(double s, Vector4d v1, Vector4d v2)
s v1 + v2
and places the result in this vector.s
- scaling factorv1
- vector to be scaledv2
- vector to be addedpublic Vector4d combine(double s1, Vector4d v1, double s2, Vector4d v2)
s1 v1 + s2 v2
and places the result in this
vector.s1
- left-hand scaling factorv1
- left-hand vectors2
- right-hand scaling factorv2
- right-hand vectorpublic double length()
public double lengthSquared()
public double distance(Vector4d v)
public double distanceSquared(Vector4d v)
public double maxElement()
maxElement
in interface Vector
maxElement
in class VectorBase
public double minElement()
minElement
in interface Vector
minElement
in class VectorBase
public double infinityNorm()
infinityNorm
in interface Vector
infinityNorm
in class VectorBase
public double oneNorm()
oneNorm
in interface Vector
oneNorm
in class VectorBase
public double dot(Vector4d v1)
v1
- right-hand vectorpublic double angle(Vector4d v1)
acos(c)
, where c
is the dot product of unit
vectors parallel to this vector and v1.v1
- right-hand vectorpublic Vector4d normalize()
public Vector4d normalize(Vector4d v1)
v1
- vector to normalizepublic boolean epsilonEquals(Vector4d v1, double eps)
v1
within a prescribed tolerance epsilon
.epsilonEquals
in interface VectorObject<Vector4d>
v1
- vector to compare witheps
- comparison tolerancepublic boolean equals(Vector4d v1)
v1
.v1
- vector to compare withpublic void setZero()
setZero
in interface VectorObject<Vector4d>
public void set(double x, double y, double z, double w)
x
- value for first elementy
- value for second elementz
- value for third elementw
- value for fourth elementpublic void set(Vector3d v, double w)
v
- vector giving the first three element valuesw
- value for the fourth elementpublic void setToHomogeneous(Vector3d v1, double w)
v1
- 3-vectorw
- weighting factorpublic Vector4d absolute()
public Vector4d absolute(Vector4d v1)
v1
- vector to take the absolute value ofpublic void sortAbsolute()
public int maxAbsIndex()
public int minAbsIndex()
public void sort(Vector4d v1)
v1
- vector to sortpublic void sort()
public Vector4d mul(Matrix4dBase X, Vector4d v1)
X
- matrixv1
- vectorpublic void transform(RotationMatrix3d R)
public void transform(RotationMatrix3d R, Vector4d v1)
public void inverseTransform(RotationMatrix3d R)
public void inverseTransform(RotationMatrix3d R, Vector4d v1)
public void inverseTransform(RigidTransform3d X)
public void inverseTransform(RigidTransform3d X, Vector4d v1)
public void transform(AffineTransform3dBase X)
public void transform(AffineTransform3dBase X, Vector4d v1)
public void setRandom()
public void setRandom(double lower, double upper)
lower
- lower random value (inclusive)upper
- upper random value (exclusive)public void setRandom(double lower, double upper, java.util.Random generator)
lower
- lower random value (inclusive)upper
- upper random value (exclusive)generator
- random number generatorpublic void updateBounds(Vector4d vmin, Vector4d vmax)
vmin
- minimum corner of the bounding boxvmax
- maximum corner of the bounding boxpublic Vector4d max(Vector4d v)
v
- vector to compare withpublic Vector4d min(Vector4d v)
v
- vector to compare withpublic Vector4d clone()
clone
in interface Clonable
clone
in class VectorBase
public void scaleObj(double s)
s
.scaleObj
in interface VectorObject<Vector4d>
public void addObj(Vector4d v1)
v1
to this vector.addObj
in interface VectorObject<Vector4d>
public void scaledAddObj(double s, Vector4d v1)
v1
by s
and adds it to this vector.scaledAddObj
in interface VectorObject<Vector4d>