|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmaspack.matrix.VectorObject
maspack.matrix.Vector4d
Implements a 4 element vector, along with its most commonly used operations.
The size of these vectors is fixed.
Field Summary | |
double |
w
Fourth element |
double |
x
First element |
double |
y
Second element |
double |
z
Third element |
Constructor Summary | |
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. |
Method Summary | |
void |
absolute()
Sets the elements of this vector to their absolute values. |
void |
absolute(Vector4d v1)
Sets the elements of this vector to the absolute value of v1. |
void |
add(Vector4d v1)
Adds this vector to v1 and places the result in this vector. |
void |
add(Vector4d v1,
Vector4d v2)
Adds vector v1 to v2 and places the result in this vector. |
double |
angle(Vector4d v1)
Returns the angle between this vector and v1. |
void |
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. |
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. |
double |
length()
Returns the 2 norm of this vector. |
double |
lengthSquared()
Returns the square of the 2 norm of 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. |
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. |
void |
negate()
Negates this vector in place. |
void |
negate(Vector4d v1)
Sets this vector to the negative of v1. |
void |
normalize()
Normalizes this vector in place. |
void |
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. |
void |
scale(double s)
Scales the elements of this vector by s . |
void |
scale(double s,
Vector4d v1)
Scales the elements of vector v1 by s and places
the results in this vector. |
void |
scaleAdd(double s,
Vector4d v1)
Computes s this + v1 and places
the result in this vector. |
void |
scaleAdd(double s,
Vector4d v1,
Vector4d v2)
Computes s v1 + v2 and places
the result in this vector. |
void |
set(double[] values)
Sets the elements of this vector from an array of doubles. |
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(Vector4d v1)
Sets the values of this vector to those of v1. |
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. |
void |
sub(Vector4d v1)
Subtracts v1 from this vector and places the result in this vector. |
void |
sub(Vector4d v1,
Vector4d v2)
Subtracts vector v1 from v2 and places the result in this vector. |
Methods inherited from class maspack.matrix.VectorObject |
dot, epsilonEquals, equals, equals, get, isFixedSize, norm, normSquared, scan, set, setSize, toString, toString, toString |
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public double x
public double y
public double z
public double w
Constructor Detail |
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 elementMethod Detail |
public int size()
size
in class VectorObject
public double get(int i)
get
in class VectorObject
i
- element index
public void get(double[] values)
get
in class VectorObject
values
- array into which values are copiedpublic void set(int i, double value)
set
in class VectorObject
i
- element indexvalue
- element value
public void set(double[] values)
set
in class VectorObject
values
- array from which values are copiedpublic void set(Vector4d v1)
v1
- vector whose values are copiedpublic void add(Vector4d v1, Vector4d v2)
v1
- left-hand vectorv2
- right-hand vectorpublic void add(Vector4d v1)
v1
- right-hand vectorpublic void sub(Vector4d v1, Vector4d v2)
v1
- left-hand vectorv2
- right-hand vectorpublic void sub(Vector4d v1)
v1
- right-hand vectorpublic void negate(Vector4d v1)
v1
- vector to negatepublic void negate()
public void scale(double s)
s
.
s
- scaling factorpublic void 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 void scaleAdd(double s, Vector4d v1)
s this + v1
and places
the result in this vector.
s
- scaling factorv1
- vector to be addedpublic void scaleAdd(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 void 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 class VectorObject
public double minElement()
minElement
in class VectorObject
public double infinityNorm()
infinityNorm
in class VectorObject
public double oneNorm()
oneNorm
in class VectorObject
public double dot(Vector4d v1)
v1
- right-hand vector
public double angle(Vector4d v1)
acos(c)
, where c
is the dot product of unit vectors parallel to this vector and v1.
v1
- right-hand vector
public void normalize()
public void normalize(Vector4d v1)
v1
- vector to normalizepublic boolean epsilonEquals(Vector4d v1, double eps)
v1
within a
prescribed tolerance epsilon
.
v1
- vector to compare witheps
- comparison tolerance
public boolean equals(Vector4d v1)
v1
.
v1
- vector to compare with
public void setZero()
public void set(double x, double y, double z, double w)
x
- value for first elementy
- value for second elementz
- value for third elementpublic void setToHomogeneous(Vector3d v1, double w)
v1
- 3-vectorw
- weighting factorpublic void absolute()
public void 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 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 generator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |