JavaView® v2.00.008

jv.vecmath
Class PdVector

java.lang.Object
  |
  +--jv.vecmath.P_Vector
        |
        +--jv.vecmath.PdVector
All Implemented Interfaces:
java.io.Serializable

public class PdVector
extends P_Vector

Linear algebra class for an array of doubles with variable length. Many non-linear operations implemented too.

Version:
08.11.00, 1.20 revised (kp) Replace string formatting routines of Fmt with PuString.
29.08.00, 1.10 revised (ur) Sort methods added.
00.00.97, 1.00 created (kp)
Author:
Konrad Polthier
See Also:
Serialized Form

Field Summary
 double[] m_data
          Data array containing the components of the vector.
 
Fields inherited from class jv.vecmath.P_Vector
BITS, m_bits, m_constraint, m_name, MASK, NUM_BITS
 
Constructor Summary
PdVector()
          Constructor, should only be used by experts, usually call PdVector(int aSize).
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.
 
Method Summary
 void add(double val)
          Add argument to each component of vector.
 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 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.
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 at vertices of a (possibly non-convex) polygon.
static double angleWithOrientation(PdVector v, PdVector w, PdVector orient)
          Compute signed angle 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.
 void blend(double a, PdVector v, double b, PdVector w)
          Interpolate between two vectors with given weights.
 void blendBase(PdVector v, double b, PdVector w)
          Interpolate between two vectors with given weights.
static PdVector blendNew(double a, PdVector v, double b, PdVector w)
          Create a new vector this = a*v + b*w.
 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()
          Duplicate vector and data array.
 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 a vector into a vector, and adjust size of dest vector only 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 crossproduct of given argument vectors.
static PdVector crossNew(PdVector v, PdVector w)
          Create new vector with crossproduct of given argument vectors.
 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 vectors.
 boolean equals(double[] list)
          Compare vector with list of doubles and return false if different array lengths or a different entry.
 boolean equals(PdVector vec)
          Determines whether another vector is equal to this vector.
 boolean equals(PdVector vec, double eps)
          Determines whether another vector is equal to this vector.
 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)
          Compute orientation of a frame of n vectors in R^n.
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.
 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 vector with matrix this = m*(v,1).
 void leftMultMatrix(PdMatrix m)
          Multiply vector with matrix this = m*this.
 void leftMultMatrix(PdMatrix m, PdVector v)
          Multiply vector with matrix this = m*v.
 double length()
          Get euclidean length of vector.
 double max()
          Find maximal value of component in vector.
static boolean max(PdVector max, PdVector[] aVecArray, 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.
static boolean min(PdVector min, PdVector[] aVecArray, 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 normal vector to a plane given by three points.
 void normalToVector(PdVector v)
          Compute an arbitrary vector orthogonal to a given vector. this=normal
static PdVector normalToVectorNew(PdVector v)
          Create a new arbitrary vector orthogonal to a given vector.
 void orthogonalize(PdVector e)
          Remove part of 'this' in direction of e, assume |e|=1, v = v - e
 PdVector orthogonalPart(PdVector vCompl, PdVector e)
          Remove part of 'this' in direction of e, assume |e|=1, vCompl = v - e.
 PdVector orthogonalPartWrtONB(PdVector e1, PdVector e2)
          Return orthogonal part of 'this' w.r.t. e_i, assume |e_i|=1, =0 v_compl = v - e_1 - e_2
 void orthonormalize(PdVector e)
          Remove part of 'this' in direction of e, assume |e|=1, v = v - e
 PdVector projectOntoONB(PdVector e1, PdVector e2)
          Project onto ONB e_i, assume |e_i|=1, =0 v_proj = e_1 + e_2
static PdVector[] realloc(PdVector[] data, int arraySize)
          Allocate an array of vectors, where all vectors have the same dimension.
static PdVector[] realloc(PdVector[] data, int arraySize, int vectorSize)
          Allocate an array of vectors, where all vectors have the same dimension.
 void rightMultMatrix(PdMatrix m)
          Multiply vector with matrix this = this*m.
 void rightMultMatrix(PdVector v, PdMatrix m)
          Multiply vector with matrix this = v*m.
 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[] aVecArray, double aValue)
          Set all components of all vectors of an array to a constant.
static void setConstant(PdVector[] aVecArray, double[] data)
          Set all vectors of an array equal to a given vector.
static void setConstant(PdVector[] aVecArray, 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 sort()
          Sort entries of this PdVector by size.
 void sort(PdVector vecOut)
          Fill OutVector with sorted entries of this PdVector.
 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.
 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.
 
Methods inherited from class jv.vecmath.P_Vector
clearTag, clone, clone, copy, getBits, getName, hasTag, setName, setTag
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_data

public double[] m_data
Data array containing the components of the vector. Array has public access for efficiency reasons in numerical computations, although method access should be preferred. Do not modify length of array directly.
Constructor Detail

PdVector

public PdVector()
Constructor, should only be used by experts, usually call PdVector(int aSize).

PdVector

public PdVector(int aSize)
Constructor creating a vector with given dimension.

PdVector

public PdVector(double x)
Constructs a vector of length 1 and given initial data.

PdVector

public PdVector(double x,
                double y)
Constructs a vector of length 2 and given initial data.

PdVector

public PdVector(double x,
                double y,
                double z)
Constructs a vector of length 3 and given initial data.

PdVector

public PdVector(double x,
                double y,
                double z,
                double w)
Constructs a vector of length 4 and given initial data.

PdVector

public PdVector(double[] x)
Constructs a vector having same length and given initial data as given array.
Method Detail

clone

public java.lang.Object clone()
Duplicate vector and data array. Method just returns result of copyNew(PdVector).
Overrides:
clone in class java.lang.Object
See Also:
copyNew(PdVector)

getEntries

public static double[][] getEntries(PdVector[] vArr)
Return content of array of vectors as matrix of doubles.
Parameters:
vArr - Array of vectors
Returns:
2-dimensional matrix of doubles

realloc

public static PdVector[] realloc(PdVector[] data,
                                 int arraySize,
                                 int vectorSize)
Allocate an array of vectors, where all vectors have the same dimension. If argument 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.

Parameters:
data - possibly empty array of vectors
arraySize - number of vectors in new array
vectorSize - dimension of vectors in new array
See Also:
realloc(PdVector [], int)

realloc

public static PdVector[] realloc(PdVector[] data,
                                 int arraySize)
Allocate an array of vectors, where all vectors have the same dimension. If argument data!=null then as most as possible of the existing vectors are reused in the reallocated array.

If requested array size is 0 then method returns an array of length 0.

Parameters:
data - possibly empty array of vectors
arraySize - number of vectors in new array
See Also:
realloc(PdVector [], int, int)

copyNew

public static PdVector[] copyNew(double[][] data)
Create an new array with copies of all doubles of a given 2-dimensional array of numbers. Each row of argument vector is stored in a vector. Rows may have different length. A row with length zero leads to a warning message, and allocates a vector with length zero.
Parameters:
data - 2-dimensional array of numbers
Returns:
new array with same number of vectors as rows of argument array
See Also:
copyNew(PdVector [], int), copy(PdVector [], int, PdVector [], int, int)

copyNew

public static PdVector[] copyNew(PdVector[] data)
Create an new array with copies of all vectors of a given array of vectors. The new array contains new vectors containing the same data as the original vectors.
Parameters:
data - array of vectors
Returns:
new array with same number of vectors as argument array
See Also:
copyNew(PdVector [], int), copy(PdVector [], int, PdVector [], int, int)

copyNew

public static PdVector[] copyNew(PdVector[] data,
                                 int size)
Create an new array with copies of the first 'size' vectors of a given array of vectors. The new array contains new vectors containing the same data as the original vectors.
Parameters:
data - array of vectors
size - number of copied vectors of array
Returns:
new array with number of vectors equal to argument 'size'
See Also:
copyNew(PdVector []), copy(PdVector [], int, PdVector [], int, int)

copy

public 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. All vectors in source and destination array must exist already.
   for (int i=0; i
 Destination array must be large enough, i.e. dataDest.length >= destInd+size.
Parameters:
dataDest - destination array of vectors
destInd - index of first destination vector in dataDest
dataSrc - source array of vectors
srcInd - index of first source vector in dataSrc used for copying
size - number of copied vectors of array
Returns:
true if destination array is large enough
See Also:
copy(PdVector)

getSameSize

public static int getSameSize(PdVector[] vecArray,
                              int numUsed)
Check of all vectors in array of vector have same length.
Returns:
same length, or -1 if different or no entries.

min

public static final boolean min(PdVector min,
                                PdVector[] aVecArray,
                                int arrayLength)
Find the minimum of an array of vectors in each component. Vectors of array may have different length. Any comparision is between the resulting vector and a vector of the array is done for the common number of components.
Parameters:
min - computed minimum
aVecArray - array of vectors
arrayLength - number of used vectors of array
See Also:
max(PdVector, PdVector [], int)

max

public static final boolean max(PdVector max,
                                PdVector[] aVecArray,
                                int arrayLength)
Find the maximum of an array of vectors in each component. Vectors of array may have different length. Any comparision is between the resulting vector and a vector of the array is done for the common number of components.
Parameters:
max - computed maximum
aVecArray - array of vectors
arrayLength - number of used vectors of array
See Also:
min(PdVector, PdVector [], int)

setConstant

public static void setConstant(PdVector[] aVecArray,
                               double aValue)
Set all components of all vectors of an array to a constant.

setConstant

public static void setConstant(PdVector[] aVecArray,
                               double[] data)
Set all vectors of an array equal to a given vector. All vectors of argument array must have same length.

setConstant

public static void setConstant(PdVector[] aVecArray,
                               PdVector aVector)
Set all vectors of an array equal to a given vector. All vectors of argument array must have same length.

setConstant

public static void setConstant(PdVector v,
                               double aValue)
Set all entries to a constant value.

setConstant

public void setConstant(double aValue)
Set all entries to a constant value.

getOrientation

public static double getOrientation(PdVector[] v)
Compute orientation of a frame of n vectors in R^n.
Returns:
double determinant of vectors

area

public static double area(PdVector p,
                          PdVector q,
                          PdVector r)
Compute area of triangle spanned by vertices {p,q,r} in some R^m. TODO: method could be made faster by using simplex formula: area = 1/2 * sqrt(det(df*df)).

area

public static double area(PdVector[] p)
Compute area of planar n-gon spanned by vertices p[] in some R^m. Total area is computed as sum of area of triangles {p[0],p[j-1],p[j]}. TODO: method could be made faster by using simplex formula: area = 1/fak(m) * sqrt(det(df*df)).

angle

public static double angle(PdVector p,
                           PdVector q,
                           PdVector r)
Compute angle of triangle (p, q, r) at vertex p.

angle

public static void angle(double[] angle,
                         PdVector p,
                         PdVector q,
                         PdVector r)
Compute interior angles at all three vertices of a triangle.

angle

public static void angle(double[] angle,
                         PdVector[] p)
Compute interior angles at all vertices of a convex polygon.

angleWithOrientation

public static double angleWithOrientation(double[] angle,
                                          PdVector[] p,
                                          int len)
Compute exterior angles at vertices of a (possibly non-convex) polygon. If p0, p1, p2 are three successive vertices with edges 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.

Parameters:
angle - array will contain the computed angles.
p - array with given polygon vertices.
len - used number of entries of both arrays.
Returns:
sum of all vertex angles.

angle

public static double angle(PdVector v,
                           PdVector w)
Compute angle between two vectors.
Returns:
angle in (-180.,180.), or 0. in case of error.

angleWithOrientation

public static double angleWithOrientation(PdVector v,
                                          PdVector w,
                                          PdVector orient)
Compute signed angle between two vectors depending on the orientation. Sign of angle is equal to orientation of frame (v,w,orient).
Returns:
angle in (-pi,pi), or 0. in case of error.

dot

public static double dot(PdVector v,
                         PdVector w)
Scalar product of two vectors.

sqrDist

public static double sqrDist(PdVector v,
                             PdVector w)
Square of the distance of two points.

dist

public static double dist(PdVector v,
                          PdVector w)
Distance of two points.

getSize

public int getSize()
Get dimension of vector, i.e. length of its data array.

setSize

public int setSize(int aSize)
Set dimension of vector, i.e. length of its data array.
Parameters:
new - number of components of vector
Returns:
new number of components of vector

getEntries

public double[] getEntries()
Return a copy of the content of vector as array of doubles.

getEntry

public double getEntry(int ind)
Get the component of a vector.

setEntry

public void setEntry(int ind,
                     double value)
Assign value to component of vector, and possibly enlarge vector if too small.

setEntry

public void setEntry(int ind,
                     int value)
Assign value to component of vector, and possibly enlarge vector if too small.
See Also:
#setEntry(double , int)

getFirstEntry

public double getFirstEntry()
Get the first component of a vector.
Returns:
value of the first component.

setFirstEntry

public void setFirstEntry(double value)
Set the first component of a vector.
Parameters:
value - new value of first component

getLastEntry

public double getLastEntry()
Get the last component of a vector.
Returns:
value of the last component.

setLastEntry

public void setLastEntry(double value)
Set the last component of a vector.
Parameters:
value - new value of last component

addEntry

public int addEntry(double val)
Add another entry at the end of the vector and increment size of vector.
Parameters:
value - to be added
Returns:
index of new last entry.

set

public 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.

set

public 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.

set

public void set(double[] x,
                int len)
Assign first values of double array to vector, and adjust length of vector if different from argument len.

set

public void set(double[] x)
Assign values of double array to vector, and adjust length of vector if different from length of array.

set

public 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.
See Also:
set(double [], int, int)

set

public void set(int[] x,
                int len)
Assign first values of integer array to vector, and adjust length of vector if different from argument len.
See Also:
set(double [], int)

set

public void set(int[] x)
Assign values of vector from integer array, and adjust length of vector if different from length of array.
See Also:
set(double [])

set

public void set(double x)
Assign value to vector, and increase size of vector if necessary.

set

public void set(double x,
                double y)
Assign value to vector, and increase size of vector if necessary.

set

public void set(double x,
                double y,
                double z)
Assign value to vector, and increase size of vector if necessary.

set

public void set(double x,
                double y,
                double z,
                double w)
Assign value to vector, and increase size of vector if necessary.

changeValue

public 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. The other entries are not used and initialized to zero. If by chance 'oldValue' is zero then these initialization would be spoiled, which is very error prone. return number of changed positions

changeValue

public int changeValue(double oldValue,
                       double newValue)
Change all occurrence of value oldValue to newValue COMPARE: changeValue(int, double, double) return number of changed positions

invert

public void invert(int usedSize)
Invert order of the first 'usedSize' entries, i.e. the first entry becomes the 'usedSize-1' entry.
See Also:
invert()

invert

public void invert()
Invert order of all entries, i.e. the first entry becomes the last entry.
See Also:
invert(int)

add

public void add(double val)
Add argument to each component of vector.

add

public void add(PdVector m)
Sum with argument vector this += m.

add

public void add(PdVector m1,
                PdVector m2)
Sum of argument vectors this = m1+m2.

sub

public void sub(PdVector m)
Difference with argument vector this = this-m.

sub

public void sub(PdVector m1,
                PdVector m2)
Difference of argument vectors this = m1-m2.

addNew

public static PdVector addNew(PdVector m1,
                              PdVector m2)
Create a new vector as sum of argument vectors new = m1+m2.

subNew

public static PdVector subNew(PdVector m1,
                              PdVector m2)
Create a new vector as difference of argument vectors new = m1-m2.

copyNew

public static PdVector copyNew(PdVector v)
Create a new vector as clone of argument vector.
Parameters:
v - source vector to clone

copy

public boolean copy(int destInd,
                    PdVector dataSrc,
                    int srcInd,
                    int size)
Copy part of a vector into a vector, and adjust size of dest vector only it is too small. Method copies nothing beside a segment of the data array.
See Also:
copy(PdVector)

copy

public void copy(PdVector v)
Copy a vector into a vector, and do not adjust size of dest vector. If destination vector is empty then allocated space of size of source vector. If source and destination vectors have different size then use the mininum of both sizes. If destination vector is bigger than source then reset the additional entries in destination vector with 0.
Parameters:
v - source vector to copy
See Also:
copy(int,PdVector,int,int)

copyArray

public void copyArray(PdVector v)
Copy data array of source vector into this vector, and do not adjust size of dest vector. In contrast to #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 mininum of both sizes for copying. If destination vector is bigger than source then reset the additional entries in destination vector with 0.
Parameters:
v - source vector to copy
See Also:
copy(PdVector)

copy

public void copy(double[] anArray,
                 int aSize)
Copy a double array into a vector, and do not adjust size of dest vector. If destination vector is empty then allocated space of size of source array. If source and destination vectors have different size then use the mininum of both sizes. If destination vector is bigger than source then reset the additional entries in destination vector with 0.
See Also:
copy(int,PdVector,int,int), copy(double [], int, int)

copy

public 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. If destination vector is empty then allocated space of size of source array. If parameter size and length of destination vectors are different then use the mininum of both sizes. If destination vector is bigger than argument size then reset the additional entries in destination vector with 0.
Parameters:
anArray - array of doubles
srcPos - first position in array used for copying
size - number of entries to copy.
See Also:
copy(double [], int)

multScalar

public void multScalar(double scalar)
Multiply vector with scalar this = scalar*this.

multScalar

public void multScalar(PdVector v,
                       double scalar)
Multiply argument vector with scalar this = scalar*v.

leftMultMatrix

public void leftMultMatrix(PdMatrix m)
Multiply vector with matrix this = m*this. Matrix must be square and of same size than vector. Method does not change size of 'this'!

leftMultAffin

public void leftMultAffin(PdMatrix m,
                          PdVector v,
                          boolean bPoint)
Multiply vector with matrix this = m*(v,1). Matrix must be square. After multiplication vector is divided by m[len][]*(v,1).
Parameters:
m - Transformation matrix, square.
v - source vector whose dimension is 1 smaller than m.
bPoint - if true then v is a point else a vector

leftMultMatrix

public void leftMultMatrix(PdMatrix m,
                           PdVector v)
Multiply vector with matrix 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.

rightMultMatrix

public void rightMultMatrix(PdMatrix m)
Multiply vector with matrix this = this*m. Matrix must be square and have the same size as than this vector. Method does not change size of this vector!

rightMultMatrix

public void rightMultMatrix(PdVector v,
                            PdMatrix m)
Multiply vector with matrix 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.

dot

public double dot(PdVector v)
Compute scalar product with argument vector.

sqrLength

public double sqrLength()
Get square of euclidean length of vector.

length

public double length()
Get euclidean length of vector.

normalize

public boolean normalize()
Normalize vector to unit length.

normalize

public boolean normalize(PdVector v)
Set vector to normalized argument vector.

setLength

public boolean setLength(double aLength)
Set euclidean length of vector.

blendNew

public static PdVector blendNew(double a,
                                PdVector v,
                                double b,
                                PdVector w)
Create a new vector this = a*v + b*w.
See Also:
blend(double, PdVector, double, PdVector), blendBase(PdVector, double, PdVector)

blend

public void blend(double a,
                  PdVector v,
                  double b,
                  PdVector w)
Interpolate between two vectors with given weights. Uses 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.
Parameters:
v - first vector
a - weight of vector v
w - second vector
b - weight of vector w
See Also:
blendBase(PdVector, double, PdVector), blendNew(double, PdVector, double, PdVector)

blendBase

public void blendBase(PdVector v,
                      double b,
                      PdVector w)
Interpolate between two vectors with given weights. Uses this = v + 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.
Parameters:
v - first vector
w - second vector
b - weight of vector w
See Also:
blend(double, PdVector, double, PdVector), blendNew(double, PdVector, double, PdVector)

dist

public double dist(PdVector v)
Euclidean distance dist = |this-v|.

sqrDist

public double sqrDist(PdVector v)
Square of euclidean distance sqrDist = |this-v|^2.

max

public double max()
Find maximal value of component in vector.
Returns:
value of maximal component
See Also:
min(), indexOfMax(), indexOfAbsMax()

maxAbs

public double maxAbs()
Find maximal absolute value of component in vector.
Returns:
absolute value of maximal absolute component
See Also:
min(), indexOfMax(), indexOfAbsMax()

min

public double min()
Find minimal value of component in vector.
Returns:
value of minimal component
See Also:
max(), indexOfMin(), indexOfAbsMin()

indexOfAbsMax

public int indexOfAbsMax()
Find component in vector with maximal absolute value.
Returns:
index of maximal absolute component
See Also:
max(), indexOfMax()

indexOfAbsMin

public int indexOfAbsMin()
Find component in vector with minimal absolute value.
Returns:
index of minimal absolute component
See Also:
min(), indexOfMin()

indexOfMax

public int indexOfMax()
Find component in vector with maximal value.
Returns:
index of maximal component
See Also:
indexOfAbsMax()

indexOfMin

public int indexOfMin()
Find component in vector with minimal value.
Returns:
index of minimal component
See Also:
indexOfAbsMin()

sort

public void sort(PdVector vecOut)
Fill OutVector with sorted entries of this PdVector.

sort

public void sort()
Sort entries of this PdVector by size.

cross

public boolean cross(PdVector v,
                     PdVector w)
Compute crossproduct of given argument vectors. Argument vectors may have different dimensions in {1,2,3}. Dimension of 'this' must be 3.
See Also:
crossNew(PdVector, PdVector)

crossNew

public static PdVector crossNew(PdVector v,
                                PdVector w)
Create new vector with crossproduct of given argument vectors.
See Also:
cross(PdVector, PdVector)

invStereoProj

public void invStereoProj(double x,
                          double y)
Map point (x,y) in R2 onto unit sphere S2 in R3 using inverse of stereographic projection.

orthogonalize

public void orthogonalize(PdVector e)
Remove part of 'this' in direction of e, assume |e|=1, v = v - e
Parameters:
e - unit vector.

orthonormalize

public void orthonormalize(PdVector e)
Remove part of 'this' in direction of e, assume |e|=1, v = v - e
Parameters:
e - unit vector.

orthogonalPart

public PdVector orthogonalPart(PdVector vCompl,
                               PdVector e)
Remove part of 'this' in direction of e, assume |e|=1, vCompl = v - e. Returned vector will be orthogonal to vector e.
Parameters:
vCompl - result vector, if null then it will be allocated.
e - unit vector.
Returns:
complement vector will be orthogonal to e

orthogonalPartWrtONB

public PdVector orthogonalPartWrtONB(PdVector e1,
                                     PdVector e2)
Return orthogonal part of 'this' w.r.t. e_i, assume |e_i|=1, =0 v_compl = v - e_1 - e_2
Parameters:
e1 - unit vector.
e2 - unit vector.
Returns:
complement vector will be orthogonal to e1 and e2.

projectOntoONB

public PdVector projectOntoONB(PdVector e1,
                               PdVector e2)
Project onto ONB e_i, assume |e_i|=1, =0 v_proj = e_1 + e_2

normalOfPlane

public boolean normalOfPlane(PdVector p,
                             PdVector q,
                             PdVector r)
Compute normal vector to a plane given by three points.

normalToVector

public void normalToVector(PdVector v)
Compute an arbitrary vector orthogonal to a given vector. this=normal

equals

public boolean equals(double[] list)
Compare vector with list of doubles and return 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.
Parameters:
list - the list of doubles to compare with
Returns:
true if the objects are the same; false otherwise.

equals

public boolean equals(PdVector vec)
Determines whether another vector is equal to this vector. The result is 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.
Parameters:
vec - the vector to compare with
Returns:
true if the objects are the same; false otherwise.

equals

public boolean equals(PdVector vec,
                      double eps)
Determines whether another vector is equal to this vector. The result is 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.
Parameters:
vec - the vector to compare with
eps - distance for equality check
Returns:
true if the objects are the same; false otherwise.

normalToVectorNew

public static PdVector normalToVectorNew(PdVector v)
Create a new arbitrary vector orthogonal to a given vector.

toString

public java.lang.String toString()
Create a multi-line string representation of the vector with detailed information about all instance variables.
Overrides:
toString in class P_Vector
See Also:
toShortString()

toShortString

public java.lang.String toShortString()
Create a single-line string representation of the vector components and attributes.
See Also:
toString()

JavaView® v2.00.008

The software JavaView® is copyright protected. All Rights Reserved.