public class PdVector extends P_Vector implements java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
double[] |
m_data
Data array containing the components of the vector.
|
Constructor and Description |
---|
PdVector()
Construct vector with zero size.
|
PdVector(double x)
Constructs a vector of length 1 and given initial data.
|
PdVector(double[] x)
Constructs a vector having same length and given initial data as given array.
|
PdVector(double x,
double y)
Constructs a vector of length 2 and given initial data.
|
PdVector(double x,
double y,
double z)
Constructs a vector of length 3 and given initial data.
|
PdVector(double x,
double y,
double z,
double w)
Constructs a vector of length 4 and given initial data.
|
PdVector(int aSize)
Constructor creating a vector with given dimension.
|
Modifier and Type | Method and Description |
---|---|
void |
add(double val)
Add argument to each component of vector.
|
void |
add(double scale,
PdVector v)
Add
scale*v to this . |
void |
add(PdVector m)
Sum with argument vector
this += m . |
void |
add(PdVector m1,
PdVector m2)
Sum of argument vectors
this = m1+m2 . |
int |
addEntry(double val)
Add another entry at the end of the vector and increment size of vector.
|
static PdVector |
addNew(PdVector m1,
PdVector m2)
Create a new vector as sum of argument vectors
new = m1+m2 . |
static PdVector[][] |
alloc(int sizeI,
int sizeJ,
int vectorSize)
Allocate a new array of vectors, where all vectors have the same dimension.
|
static void |
angle(double[] angle,
PdVector[] p)
Compute interior angles at all vertices of a convex polygon.
|
static void |
angle(double[] angle,
PdVector p,
PdVector q,
PdVector r)
Compute interior angles at all three vertices of a triangle.
|
static double |
angle(PdVector v,
PdVector w)
Compute angle between two vectors in (0.,180.).
|
static double |
angle(PdVector p,
PdVector q,
PdVector r)
Compute angle of triangle (p, q, r) at vertex p.
|
static double |
angleWithOrientation(double[] angle,
PdVector[] p,
int len)
Compute exterior angles in radians at vertices of a (possibly non-convex) polygon.
|
static double |
angleWithOrientation(PdVector v,
PdVector w,
PdVector orient)
Compute signed angle in radians between two vectors depending on the orientation.
|
static double |
area(PdVector[] p)
Compute area of planar n-gon spanned by vertices p[] in some R^m.
|
static double |
area(PdVector p,
PdVector q,
PdVector r)
Compute area of triangle spanned by vertices {p,q,r} in some R^m.
|
double |
average()
Compute the average of all entries.
|
void |
blend(double a,
PdVector v,
double b,
PdVector w)
Interpolate between two vectors with given weights.
|
void |
blend(double a,
PdVector u,
double b,
PdVector v,
double c,
PdVector w)
Interpolate between three vectors with given weights.
|
void |
blend(double a,
PdVector u,
double b,
PdVector v,
double c,
PdVector w,
double d,
PdVector x)
Interpolate between four vectors with given weights.
|
void |
blendBase(PdVector u,
double b,
PdVector v)
Interpolate between two vectors with given weights.
|
void |
blendBase(PdVector u,
double b,
PdVector v,
double c,
PdVector w)
Interpolate between three vectors with given weights.
|
static PdVector |
blendNew(double a,
PdVector v,
double b,
PdVector w)
Create a new vector
this = a*v + b*w . |
static PdVector |
blendNew(double a,
PdVector u,
double b,
PdVector v,
double c,
PdVector w)
Create a new vector
this = u*a + v*b + w*c . |
static PdVector |
blendNew(double a,
PdVector u,
double b,
PdVector v,
double c,
PdVector w,
double d,
PdVector x)
Create a new vector
this = u*a + v*b + w*c + x'd . |
int |
changeValue(double oldValue,
double newValue)
Change all occurrence of value oldValue to newValue
COMPARE: changeValue(int, double, double)
return number of changed positions
|
int |
changeValue(int usedSize,
double oldValue,
double newValue)
Change occurrence of value oldValue to newValue on first 'usedSize' positions
difference to method changeValue(double, double): sometime we use vectors where
only the first entries are used.
|
java.lang.Object |
clone()
Clone object and all instance variables.
|
void |
concat(PdVector pdv)
Concatenates another PdVector to the end of this vector.
|
void |
copy(double[] anArray,
int aSize)
Copy a double array into a vector, and do not adjust size of dest vector.
|
void |
copy(double[] anArray,
int srcPos,
int aSize)
Copy part of a double array into a vector, and do not adjust size of dest vector.
|
boolean |
copy(int destInd,
PdVector dataSrc,
int srcInd,
int size)
Copy part of the source vector into this vector, and adjust size of this vector
only if it is too small.
|
void |
copy(PdVector v)
Copy a vector into a vector, and do not adjust size of dest vector.
|
static boolean |
copy(PdVector[] dataDest,
int destInd,
PdVector[] dataSrc,
int srcInd,
int size)
Copies some vectors of a given array of vectors into an existing destination array.
|
void |
copyArray(PdVector v)
Copy data array of source vector into this vector, and do not adjust size of dest vector.
|
static PdVector[] |
copyNew(double[][] data)
Create an new array with copies of all doubles of a given 2-dimensional array of numbers.
|
static PdVector |
copyNew(PdVector v)
Create a new vector as clone of argument vector.
|
static PdVector[] |
copyNew(PdVector[] data)
Create an new array with copies of all vectors of a given array of vectors.
|
static PdVector[] |
copyNew(PdVector[] data,
int size)
Create an new array with copies of the first 'size' vectors of a given array of vectors.
|
boolean |
cross(PdVector v,
PdVector w)
Compute cross product of given argument vectors.
|
static PdVector |
crossNew(PdVector v,
PdVector w)
Create new vector with cross product of given argument vectors.
|
static double |
det(PdVector[] v)
Compute determinant of a frame of
n vectors in R^n . |
static double |
det(PdVector v,
PdVector w,
PdVector t)
Compute determinant of a frame of three vectors in
R^3 . |
double |
dist(PdVector v)
Euclidean distance
dist = |this-v| . |
static double |
dist(PdVector v,
PdVector w)
Distance of two points.
|
double |
dot(PdVector v)
Compute scalar product with argument vector.
|
static double |
dot(PdVector v,
PdVector w)
Scalar product of two given vectors.
|
static double |
dot(PdVector p,
PdVector q,
PdVector r)
Scalar product of two vectors v:=q-p and w:=r-p determined by given vertices.
|
static double |
dotDir(PdVector v,
PdVector q,
PdVector p)
Scalar product of two vectors v and w:=q-p determined by given vertices.
|
boolean |
equals(double[] list)
Compare vector with list of doubles and return
false if different
array lengths or a different entry. |
boolean |
equals(java.lang.Object obj)
Determines whether another vector or array of doubles is equal to this vector.
|
boolean |
equals(PdVector v)
Determines whether another vector is equal to this vector.
|
boolean |
equals(PdVector v,
double eps)
Determines whether another vector is equal to this vector.
|
static PdVector |
flatten(PdVector[] data)
Flatten out array of vectors.
|
static PdVector |
flatten(PdVector[] data,
PdVector flat)
Flatten out an array of vectors.
|
double[] |
getEntries()
Return a copy of the content of vector as array of doubles.
|
static double[][] |
getEntries(PdVector[] vArr)
Return content of array of vectors as matrix of doubles.
|
double |
getEntry(int ind)
Get the component of a vector.
|
double |
getFirstEntry()
Get the first component of a vector.
|
double |
getLastEntry()
Get the last component of a vector.
|
static double |
getOrientation(PdVector[] v)
Deprecated.
since JavaView 2.92.000, use same method det().
|
static int |
getSameSize(PdVector[] vecArray,
int numUsed)
Check of all vectors in array of vector have same length.
|
int |
getSize()
Get dimension of vector, i.e. length of its data array.
|
int |
indexOfAbsMax()
Find component in vector with maximal absolute value.
|
int |
indexOfAbsMin()
Find component in vector with minimal absolute value.
|
int |
indexOfMax()
Find component in vector with maximal value.
|
int |
indexOfMin()
Find component in vector with minimal value.
|
int |
indexOfValueInOrdering(double value)
Computes the index i of the first entry of vector with
v[i]<=value
in logarithmic time. |
void |
invert()
Invert order of all entries, i.e. the first entry becomes the last entry.
|
void |
invert(int usedSize)
Invert order of the first 'usedSize' entries, i.e. the first entry
becomes the 'usedSize-1' entry.
|
void |
invStereoProj(double x,
double y)
Map point (x,y) in R2 onto unit sphere S2 in R3 using inverse of stereographic projection.
|
void |
leftMultAffin(PdMatrix m,
PdVector v,
boolean bPoint)
Multiply a point resp. vector with matrix
this = m*(v,1) resp. |
PdVector |
leftMultMatrix(PdMatrix m)
Multiply vector with matrix
this = m*this . |
PdVector |
leftMultMatrix(PdMatrix m,
PdVector v)
Multiply vector with matrix
this = m*v . |
double |
length()
Get euclidean length of vector.
|
static double |
length(int num,
double[] data)
Get euclidean length of vector.
|
double |
max()
Find maximal value of component in vector.
|
boolean |
max(PdVector vec)
Find the maximum of this and a comparison vector in each component
and adjust the minimum in each component of this vector.
|
static boolean |
max(PdVector max,
PdVector[] vecArr,
int arrayLength)
Find the maximum of an array of vectors in each component.
|
double |
maxAbs()
Find maximal absolute value of component in vector.
|
double |
min()
Find minimal value of component in vector.
|
boolean |
min(PdVector vec)
Find the minimum of this and a comparison vector in each component
and adjust the minimum in each component of this vector.
|
static boolean |
min(PdVector min,
PdVector[] vecArr,
int arrayLength)
Find the minimum of an array of vectors in each component.
|
void |
multScalar(double scalar)
Multiply vector with scalar
this = scalar*this . |
void |
multScalar(PdVector v,
double scalar)
Multiply argument vector with scalar
this = scalar*v . |
boolean |
normalize()
Normalize vector to unit length.
|
boolean |
normalize(PdVector v)
Set vector to normalized argument vector.
|
boolean |
normalOfPlane(PdVector p,
PdVector q,
PdVector r)
Compute unit normal vector to a plane given by three points.
|
void |
normalToVector(PdVector v)
Compute an arbitrary vector orthonormal to a given unit vector v, assume |v|==1.
|
static PdVector |
normalToVectorNew(PdVector v)
Create a new arbitrary vector orthogonal to a given unit vector.
|
void |
orthogonalize(PdVector e)
Remove part of 'this' in direction of e, assume |e|=1,
v = v - <v,e>e . |
PdVector |
orthogonalPart(PdVector vCompl,
PdVector e)
Remove part of 'this' in direction of e, assume |e|=1,
vCompl = v - <v,e>e . |
PdVector |
orthogonalPartWrtONB(PdVector e1,
PdVector e2)
Return orthogonal part of 'this' w.r.t. e_i, assume |e_i|=1, < e_i,e_j >=0
v_compl = v - < v,e_1 > e_1 - < v,e_2 > e_2
|
void |
orthonormalize(PdVector e)
Remove part of 'this' in direction of e, assume |e|=1,
v = v - <v,e>e , and normalize v. |
PdVector |
projectOntoONB(PdVector e1,
PdVector e2)
Project onto ONB e_i, assume |e_i|=1, <e_i, e_j> =0
v_proj = < v,e_1 > e_1 + < v,e_2 > e_2
|
static PdVector[] |
realloc(PdVector[] data,
int arraySize)
Allocate an array of vectors.
|
static PdVector[] |
realloc(PdVector[] data,
int arraySize,
int vectorSize)
Allocate an array of vectors, where all vectors have the same dimension.
|
void |
removeEntry(int ind)
Remove an entry from the vector.
|
void |
removeSuccessiveDuplicates()
Removes all successive duplicate entries.
|
void |
rightMultMatrix(PdMatrix m)
Multiply vector with matrix
this = this*m . |
void |
rightMultMatrix(PdVector v,
PdMatrix m)
Multiply vector with matrix
this = v*m . |
static boolean |
scale(PdVector[] bnd,
PdVector[] vecArr,
int arrayLength)
Affine scaling of an array of vectors to lie in a given bounding volume.
|
void |
set(double x)
Assign value to vector, and increase size of vector if necessary.
|
void |
set(double[] x)
Assign values of double array to vector,
and adjust length of vector if different from length of array.
|
void |
set(double[] x,
int len)
Assign first values of double array to vector,
and adjust length of vector if different from argument len.
|
void |
set(double[] x,
int from,
int len)
Assign 'len' values of double array starting at 'from' to vector,
and adjust length of vector if different from argument len.
|
void |
set(double x,
double y)
Assign value to vector, and increase size of vector if necessary.
|
void |
set(double x,
double y,
double z)
Assign value to vector, and increase size of vector if necessary.
|
void |
set(double x,
double y,
double z,
double w)
Assign value to vector, and increase size of vector if necessary.
|
void |
set(int[] x)
Assign values of vector from integer array, and adjust length of vector if different from length of array.
|
void |
set(int[] x,
int len)
Assign first values of integer array to vector,
and adjust length of vector if different from argument len.
|
void |
set(int[] x,
int from,
int len)
Assign 'len' values of integer array starting at 'from' to vector,
and adjust length of vector if different from argument len.
|
void |
set(PdVector x,
int from,
int len)
Assign 'len' values of array starting at 'from' to vector,
and adjust length of vector if different from argument len.
|
void |
setConstant(double aValue)
Set all entries to a constant value.
|
static void |
setConstant(PdVector[] vecArr,
double aValue)
Set all components of all vectors of an array to a constant.
|
static void |
setConstant(PdVector[] vecArr,
double[] data)
Set all vectors of an array equal to a given vector.
|
static void |
setConstant(PdVector[] vecArr,
PdVector aVector)
Set all vectors of an array equal to a given vector.
|
static void |
setConstant(PdVector v,
double aValue)
Set all entries to a constant value.
|
void |
setEntry(int ind,
double value)
Assign value to component of vector, and possibly enlarge vector if too small.
|
void |
setEntry(int ind,
int value)
Assign value to component of vector, and possibly enlarge vector if too small.
|
void |
setFirstEntry(double value)
Set the first component of a vector.
|
void |
setLastEntry(double value)
Set the last component of a vector.
|
boolean |
setLength(double aLength)
Set Euclidean length of vector.
|
int |
setSize(int aSize)
Set dimension of vector, i.e. length of its data array.
|
void |
shift(int num)
Shift components in cyclic order within the array.
|
void |
sort()
Sort entries of this vector in place by increasing size.
|
PdVector |
sort(PdVector vecOut)
Sort entries of this vector into argument vector by increasing size.
|
double |
sqrDist(PdVector v)
Square of euclidean distance
sqrDist = |this-v|^2 . |
static double |
sqrDist(PdVector v,
PdVector w)
Square of the distance of two points.
|
double |
sqrLength()
Get square of euclidean length of vector.
|
void |
sub(PdVector m)
Difference with argument vector
this = this-m . |
void |
sub(PdVector m1,
PdVector m2)
Difference of argument vectors
this = m1-m2 . |
static PdVector |
subNew(PdVector m1,
PdVector m2)
Create a new vector as difference of argument vectors
new = m1-m2 . |
double |
sum()
Compute the sum of all entries.
|
java.lang.String |
toShortString()
Create a single-line string representation of the vector components and attributes.
|
java.lang.String |
toString()
Create a multi-line string representation of the vector
with detailed information about all instance variables.
|
double |
variance()
Compute the variance of the entries of a PdVector.
|
public double[] m_data
public PdVector()
public PdVector(int aSize)
public PdVector(double x)
public PdVector(double x, double y)
public PdVector(double x, double y, double z)
public PdVector(double x, double y, double z, double w)
public PdVector(double[] x)
public java.lang.Object clone()
copyNew(PdVector)
but this clone() method is consistent with possible subclasses
while copyNew() explicitly creates a new PdVector.clone
in class java.lang.Object
copyNew(PdVector)
public static double[][] getEntries(PdVector[] vArr)
vArr
- Array of vectorspublic static PdVector[][] alloc(int sizeI, int sizeJ, int vectorSize)
sizeI
- number of rows in new arraysizeJ
- number of columns in row[i] in new arrayvectorSize
- dimension of vectors in new arrayrealloc(PdVector [], int, int)
public static PdVector[] realloc(PdVector[] data, int arraySize, int vectorSize)
data!=null
then as most as possible of the content of
existing vectors is copied into (possibly reused) vectors of the
reallocated array.
If requested array size is 0 then method returns an array of length 0.
data
- possibly empty array of vectorsarraySize
- number of vectors in new arrayvectorSize
- dimension of vectors in new arrayrealloc(PdVector [], int)
public static PdVector[] realloc(PdVector[] data, int arraySize)
data!=null
then as most as possible of the
existing vectors are reused in the reallocated array. New vectors are
allocated with dimension zero.
If requested array size is 0 then method returns an array of length 0.
data
- possibly empty array of vectorsarraySize
- number of vectors in new arrayrealloc(PdVector [], int, int)
public static PdVector[] copyNew(double[][] data)
data
- 2-dimensional array of numberscopyNew(PdVector [], int)
,
copy(PdVector [], int, PdVector [], int, int)
public static PdVector[] copyNew(PdVector[] data)
data
- array of vectorscopyNew(PdVector [], int)
,
copy(PdVector [], int, PdVector [], int, int)
public static PdVector[] copyNew(PdVector[] data, int size)
data
- array of vectorssize
- number of copied vectors of arraycopyNew(PdVector [])
,
copy(PdVector [], int, PdVector [], int, int)
public static boolean copy(PdVector[] dataDest, int destInd, PdVector[] dataSrc, int srcInd, int size)
for (int i=0; iDestination array must be large enough, i.e. dataDest.length >= destInd+size
.
dataDest
- destination array of vectorsdestInd
- index of first destination vector in dataDestdataSrc
- source array of vectorssrcInd
- index of first source vector in dataSrc used for copyingsize
- number of copied vectors of arraytrue
if destination array is large enoughcopy(PdVector)
public static int getSameSize(PdVector[] vecArray, int numUsed)
public static final boolean scale(PdVector[] bnd, PdVector[] vecArr, int arrayLength)
bnd
- bounding volumevecArr
- array of vectorsarrayLength
- number of used vectors of arraypublic static final boolean min(PdVector min, PdVector[] vecArr, int arrayLength)
min
- computed minimumvecArr
- array of vectorsarrayLength
- number of used vectors of arraymin(PdVector)
,
max(PdVector, PdVector [], int)
public static final boolean max(PdVector max, PdVector[] vecArr, int arrayLength)
max
- computed maximumvecArr
- array of vectorsarrayLength
- number of used vectors of arraymin(PdVector, PdVector [], int)
,
max(PdVector)
public boolean min(PdVector vec)
vec
- comparison vectormin(PdVector, PdVector [], int)
,
max(PdVector)
public boolean max(PdVector vec)
vec
- comparison vectormax(PdVector, PdVector [], int)
,
min(PdVector)
public static void setConstant(PdVector[] vecArr, double aValue)
public static void setConstant(PdVector[] vecArr, double[] data)
public static void setConstant(PdVector[] vecArr, PdVector aVector)
public static void setConstant(PdVector v, double aValue)
public void setConstant(double aValue)
public static double getOrientation(PdVector[] v)
n
vectors in R^n
.public static double det(PdVector[] v)
n
vectors in R^n
.
This method allocates a temporary matrix and returns PdMatrix.det().
See det(PdVector, PdVector, PdVector)
for a direct method.public static double det(PdVector v, PdVector w, PdVector t)
R^3
.
No intermediate memory allocations.
See det(PdVector [])
for another method.v
- Vector in R3.w
- Vector in R3.t
- Vector in R3.public static double area(PdVector p, PdVector q, PdVector r)
public static double area(PdVector[] p)
public static double angle(PdVector p, PdVector q, PdVector r)
public static void angle(double[] angle, PdVector p, PdVector q, PdVector r)
public static void angle(double[] angle, PdVector[] p)
public static double angleWithOrientation(double[] angle, PdVector[] p, int len)
v = p1-p0
and w = p2-p1
then the
exterior vertex angle is angle = sign*acos()
.
The sign is positive at convex vertices and negative at
concave vertices, and angles are in [-PI, PI].
For a closed polygon the total sum of all angles is positive.
For planar closed polygon it is windingNumber*2PI
.
angle
- array will contain the computed angles.p
- array with given polygon vertices.len
- used number of entries of both arrays.public static double angle(PdVector v, PdVector w)
public static double angleWithOrientation(PdVector v, PdVector w, PdVector orient)
v
- vector in R^2 or R^3w
- vector in R^2 or R^3orient
- vector in R^3public static double dot(PdVector v, PdVector w)
v
- vectorw
- vectorpublic static double dot(PdVector p, PdVector q, PdVector r)
p
- base pointq
- end point of vector with base pr
- end point of vector with base ppublic static double dotDir(PdVector v, PdVector q, PdVector p)
v
- first vectorq
- end point of second vector with base pp
- base point of second vector with end qpublic static PdVector flatten(PdVector[] data)
data
- array of vectorspublic static PdVector flatten(PdVector[] data, PdVector flat)
data
- array of vectorsflat
- vector is returned, if argument is null a vector is createdpublic int getSize()
public int setSize(int aSize)
aSize
- new number of components of vectorpublic double[] getEntries()
public double getEntry(int ind)
public void setEntry(int ind, double value)
ind
- index of component.value
- new value of component.public void setEntry(int ind, int value)
ind
- index of component.value
- new value of component.setEntry(int, double)
public double getFirstEntry()
public void setFirstEntry(double value)
value
- new value of first componentpublic double getLastEntry()
public void setLastEntry(double value)
value
- new value of last componentpublic int addEntry(double val)
val
- value to be addedpublic void removeEntry(int ind)
ind
- Index of the entry to remove.public void concat(PdVector pdv)
pdv
- Vector to append to this one.public void set(PdVector x, int from, int len)
public void set(double[] x, int from, int len)
public void set(double[] x, int len)
public void set(double[] x)
public void set(int[] x, int from, int len)
set(double [], int, int)
public void set(int[] x, int len)
set(double [], int)
public void set(int[] x)
set(double [])
public void set(double x)
public void set(double x, double y)
public void set(double x, double y, double z)
public void set(double x, double y, double z, double w)
public int changeValue(int usedSize, double oldValue, double newValue)
public int changeValue(double oldValue, double newValue)
public void shift(int num)
num
- Number of positions each component is shifted.invert()
public void invert(int usedSize)
invert()
public void invert()
invert(int)
public void add(double val)
public void add(PdVector m)
this += m
. Both must be of same size.public void add(double scale, PdVector v)
scale*v
to this
.
If result vector 'this' is empty then its size is set to length of vector 'v'.
Otherwise, 'this' and v must be of same size.v
- vector to add to 'this'scale
- weight of vector vadd(PdVector)
,
add(PdVector, PdVector)
,
blendBase(PdVector, double, PdVector)
,
blend(double, PdVector, double, PdVector)
public void add(PdVector m1, PdVector m2)
this = m1+m2
.
m1, m2 and this must be of same size.public void sub(PdVector m)
this = this-m
.
Vectors m and this must be of same size.public void sub(PdVector m1, PdVector m2)
this = m1-m2
.
Vectors must be of same size.public static PdVector addNew(PdVector m1, PdVector m2)
new = m1+m2
.public static PdVector subNew(PdVector m1, PdVector m2)
new = m1-m2
.
If sizes differ then a warning is thrown and a vector of minimal common size returned.public static PdVector copyNew(PdVector v)
v
- source vector to clonepublic boolean copy(int destInd, PdVector dataSrc, int srcInd, int size)
copy(PdVector)
public void copy(PdVector v)
v
- source vector to copycopy(int,PdVector,int,int)
public void copyArray(PdVector v)
copy(PdVector)
this method does not
invoke the copy method of the superclass.
If destination vector is empty then allocated space of size of source vector.
If source and destination vectors have different size then use the minimum
of both sizes for copying. If destination vector is bigger than source then reset
the additional entries in destination vector with 0.v
- source vector to copycopy(PdVector)
public void copy(double[] anArray, int aSize)
public void copy(double[] anArray, int srcPos, int aSize)
anArray
- array of doublessrcPos
- first position in array used for copyingaSize
- number of entries to copy.copy(double [], int)
public void multScalar(double scalar)
this = scalar*this
.public void multScalar(PdVector v, double scalar)
this = scalar*v
.
Vectors v and this must be of same size.public PdVector leftMultMatrix(PdMatrix m)
this = m*this
.
Matrix must be square and of same size than vector.
Method does not change size of 'this'!public void leftMultAffin(PdMatrix m, PdVector v, boolean bPoint)
this = m*(v,1)
resp. this = m*(v,0)
.
Matrix need not be square but must have equal or more lines than the size of this vector,
and exactly one more columns than the size of the argument vector.m
- Transformation matrix, square.v
- source vector whose dimension is 1 smaller than m.bPoint
- if true then v is a point else a vectorpublic PdVector leftMultMatrix(PdMatrix m, PdVector v)
this = m*v
.
Matrix need not be square. Argument vector must have same size
as number of columns of matrix.
Method modifies size of this vector to number of rows of matrix.public void rightMultMatrix(PdMatrix m)
this = this*m
.
Matrix must be square and have the same size as than this vector.
Method does not change size of this vector!public void rightMultMatrix(PdVector v, PdMatrix m)
this = v*m
.
Matrix need not be square.
Argument vector must have same size as number of rows of matrix.
Method modifies size of vector to number of columns of matrix.public double dot(PdVector v)
public double sqrLength()
public double length()
public static double length(int num, double[] data)
num
- number of components to be used from data arraydata
- array whose euclidean length is returnedpublic boolean normalize()
public boolean normalize(PdVector v)
public boolean setLength(double aLength)
public static PdVector blendNew(double a, PdVector v, double b, PdVector w)
this = a*v + b*w
.a
- weight of first vectorv
- first vectorb
- weight of second vectorw
- second vectorblend(double, PdVector, double, PdVector)
,
blendBase(PdVector, double, PdVector)
public static PdVector blendNew(double a, PdVector u, double b, PdVector v, double c, PdVector w)
this = u*a + v*b + w*c
.a
- weight of first vectoru
- first vectorb
- weight of second vectorv
- second vectorc
- weight of third vectorw
- third vectorblend(double, PdVector, double, PdVector, double, PdVector)
public static PdVector blendNew(double a, PdVector u, double b, PdVector v, double c, PdVector w, double d, PdVector x)
this = u*a + v*b + w*c + x'd
.a
- weight of first vectoru
- first vectorb
- weight of second vectorv
- second vectorc
- weight of third vectorw
- third vectord
- weight of fourth vectorx
- fourth vectorblend(double, PdVector, double, PdVector, double, PdVector, double, PdVector)
public void blend(double a, PdVector v, double b, PdVector w)
this = v*a + w*b
.
If result vector 'this' is empty then its size is set to length of vector v,
otherwise interpolation is done up to length of result vector.a
- weight of first vectorv
- first vectorb
- weight of second vectorw
- second vectorblendBase(PdVector, double, PdVector)
,
blendNew(double, PdVector, double, PdVector)
public void blend(double a, PdVector u, double b, PdVector v, double c, PdVector w)
this = u*a + v*b + w*c
.
If result vector 'this' is empty then its size is set to length of vector v,
otherwise interpolation is done up to length of result vector.a
- weight of first vectoru
- first vectorb
- weight of second vectorv
- second vectorc
- weight of third vectorw
- third vectorblendNew(double, PdVector, double, PdVector, double, PdVector)
public void blend(double a, PdVector u, double b, PdVector v, double c, PdVector w, double d, PdVector x)
this = u*a + v*b + w*c + x*d
.
If result vector 'this' is empty then its size is set to length of vector v,
otherwise interpolation is done up to length of result vector.a
- weight of first vectoru
- first vectorb
- weight of second vectorv
- second vectorc
- weight of third vectorw
- third vectord
- weight of fourth vectorx
- fourth vectorblendNew(double, PdVector, double, PdVector, double, PdVector, double, PdVector)
public void blendBase(PdVector u, double b, PdVector v)
this = u + b*v
.
If result vector 'this' is empty then its size is set to length of vector u,
otherwise interpolation is done up to length of result vector.u
- first vectorb
- weight of second vectorv
- second vectorblend(double, PdVector, double, PdVector)
,
blendNew(double, PdVector, double, PdVector)
public void blendBase(PdVector u, double b, PdVector v, double c, PdVector w)
this = u + b*v + c*w
.
If result vector 'this' is empty then its size is set to length of vector u,
otherwise interpolation is done up to length of result vector.u
- first vector (base)b
- weight of second vectorv
- second vectorc
- weight of third vectorw
- third vectorblend(double, PdVector, double, PdVector, double, PdVector)
,
blendNew(double, PdVector, double, PdVector, double, PdVector)
,
blendBase(PdVector, double, PdVector)
public double dist(PdVector v)
dist = |this-v|
.public double sqrDist(PdVector v)
sqrDist = |this-v|^2
.public double max()
min()
,
indexOfMax()
,
indexOfAbsMax()
public double maxAbs()
min()
,
indexOfMax()
,
indexOfAbsMax()
public double min()
max()
,
indexOfMin()
,
indexOfAbsMin()
public int indexOfAbsMax()
max()
,
indexOfMax()
public int indexOfAbsMin()
min()
,
indexOfMin()
public int indexOfMax()
indexOfAbsMax()
public int indexOfMin()
indexOfAbsMin()
public int indexOfValueInOrdering(double value)
v[i]<=value
in logarithmic time. Vector must be sort by increasing values.value
- Find position of this value in order vector.v[i]<=value
or -1 if value is smaller than minimum value of vector.public double sum()
public double average()
public double variance()
public PdVector sort(PdVector vecOut)
PuMath.heapsort(int,int[],int[])
is used.
If missing or has different size then this, then size of vecOut is adjusted.
sort()
public void sort()
PuMath.heapsort(int,int[],int[])
is used.sort(PdVector)
public boolean cross(PdVector v, PdVector w)
Dimension of 'this' must be 3.
'this' may be one of the argument vectors.
v
- vector of (possibly mixed) dimensions 2 or 3.w
- vector of (possibly mixed) dimensions 2 or 3.crossNew(PdVector, PdVector)
public static PdVector crossNew(PdVector v, PdVector w)
v
- w,v: two vectors of (possibly mixed) dimensions 2 or 3.w
- w,v: two vectors of (possibly mixed) dimensions 2 or 3.cross(PdVector, PdVector)
public void invStereoProj(double x, double y)
public void orthogonalize(PdVector e)
v = v - <v,e>e
.
This vector will be orthogonal to vector e, or the zero vector.e
- unit vector.public void orthonormalize(PdVector e)
v = v - <v,e>e
, and normalize v.
This vector will be orthonormal to vector e, or the zero vector.e
- unit vector.public PdVector orthogonalPart(PdVector vCompl, PdVector e)
vCompl = v - <v,e>e
.
Returned vector will be orthogonal to vector e, or the zero vector.vCompl
- result vector, may be this vector. If null then it will be allocated.e
- unit vector.public PdVector orthogonalPartWrtONB(PdVector e1, PdVector e2)
e1
- unit vector.e2
- unit vector.public PdVector projectOntoONB(PdVector e1, PdVector e2)
public boolean normalOfPlane(PdVector p, PdVector q, PdVector r)
public void normalToVector(PdVector v)
public static PdVector normalToVectorNew(PdVector v)
public boolean equals(double[] list)
false if different
array lengths or a different entry.
Determines whether a list of doubles is equal to data of this vector.
The result is true
if both arrays have same length and
equal components. Result is also true
if argument vector
is null and this vector has no entries.
list
- the list of doubles to compare withtrue
if the objects are the same; false
otherwise.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
equals(double[])
,
equals(PdVector)
,
Object.equals(java.lang.Object)
public boolean equals(PdVector v)
true
if both vectors have same length and
equal components. Result is also true
if argument vector
is null and this vector has no entries.v
- the vector to compare withtrue
if the objects are the same; false
otherwise.public boolean equals(PdVector v, double eps)
true
if both vectors have same length and
the euclidean distance is smaller or equal than a given distance.
Result is also true
if argument vector is null and this
vector has no entries.v
- the vector to compare witheps
- distance for equality checktrue
if the objects are the same; false
otherwise.public java.lang.String toString()
toString
in class P_Vector
toShortString()
public java.lang.String toShortString()
toString()
public void removeSuccessiveDuplicates()
"