Documentation of 'jv.vecmath.PdVector' Java class
PdVector ("JavaView Reference Manual")
"JavaView? v5.03.003"
jv.vecmath

Class PdVector

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable


    public class PdVector
    extends P_Vector
    implements java.lang.Cloneable
    Linear algebra class for an array of doubles with variable length. Many non-linear operations implemented too.
    See Also:
    Serialized Form
    Author:
    Konrad Polthier
    Version:
    19.06.15, 1.61 revised (kp) Number of member accesses reduced.
    08.07.06, 1.60 revised (kp) Method clone() implemented to replace copyNew() when used by subclasses.
    29.11.04, 1.50 revised (ep) New method equals(Object).
    28.01.02, 1.30 revised (ep) Implement cloneable interface.
    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)
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      double[] m_data
      Data array containing the components of the vector.
    • Constructor Summary

      Constructors 
      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.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      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 arraySize, int vectorSize)
      Allocate an array of vectors, where all vectors have the same dimension.
      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)
      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 a non-zero-length 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 a non-zero-length 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_fastTmp(PdVector v) 
      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.
      boolean lesser(double[] list)
      Compare vector with list of doubles and return false if different array lengths or a different entry.
      boolean lesser(PdVector v)
      Determines whether another vector is lesser to this 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.
      • Methods inherited from class java.lang.Object

        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()
        Construct vector with zero size.
        Version:
        27.12.01, 1.10 revised (kp) Now allocate array with zero length.
      • 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.
        Version:
        20.07.00, 1.00 created (kp).
    • Method Detail

      • clone

        public java.lang.Object clone()
        Clone object and all instance variables. Similar like copyNew(PdVector) but this clone() method is consistent with possible subclasses while copyNew() explicitly creates a new PdVector.
        Overrides:
        clone in class P_Vector
        See Also:
        copyNew(PdVector)
        Version:
        08.07.06, 2.00 revised (kp) Now explicitly use superclass.clone().
        05.07.00, 1.00 created (kp)
      • 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
        Version:
        05.07.00, 1.00 created (kp)
      • alloc

        public static PdVector[][] alloc(int sizeI,
                                         int sizeJ,
                                         int vectorSize)
        Allocate a new array of vectors, where all vectors have the same dimension.
        Parameters:
        sizeI - number of rows in new array
        sizeJ - number of columns in row[i] in new array
        vectorSize - dimension of vectors in new array
        See Also:
        realloc(PdVector [], int, int)
        Version:
        12.12.06, 1.10 revised (ur) Bug fixed.
        27.11.06, 1.00 revised (kp)
      • 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)
        Version:
        26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
      • alloc

        public static PdVector[] alloc(int arraySize,
                                       int vectorSize)
        Allocate an array of vectors, where all vectors have the same dimension. Same as realloc(null, arraySize, vectorSize).
        Parameters:
        arraySize - number of vectors in new array
        vectorSize - dimension of vectors in new array
        See Also:
        realloc(PdVector [], int, int)
        Version:
        01.08.2012, 1.00 created (fk)
      • realloc

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

        Parameters:
        data - possibly empty array of vectors
        arraySize - number of vectors in new array
        See Also:
        realloc(PdVector [], int, int)
        Version:
        26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
      • 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)
        Version:
        24.07.00 1.00 created (kp)
      • 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<size; i++)
            dataDest[destInd+i].copy(dataSrc[srcInd+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.
      • scale

        public static final boolean scale(PdVector[] bnd,
                                          PdVector[] vecArr,
                                          int arrayLength)
        Affine scaling of an array of vectors to lie in a given bounding volume. All vectors must have the same size.
        Parameters:
        bnd - bounding volume
        vecArr - array of vectors
        arrayLength - number of used vectors of array
        Since:
        JavaView 2.45
        Version:
        09.11.02, 1.00 created (kp)
      • min

        public static final boolean min(PdVector min,
                                        PdVector[] vecArr,
                                        int arrayLength)
        Find the minimum of an array of vectors in each component. Vectors of array may have different length. Any comparison is between the resulting vector and a vector of the array is done for the common number of components.
        Parameters:
        min - computed minimum
        vecArr - array of vectors
        arrayLength - number of used vectors of array
        See Also:
        min(PdVector), max(PdVector, PdVector [], int)
        Version:
        26.04.07, 1.12 revised (fk) Use POSITIVE_INFINITY instead of MAX_VALUE.
        08.09.00, 1.11 revised (kp) Check for vecArr.length==0.
        27.12.99, 1.10 revised (kp) Allow variable length of vectors in array.
      • max

        public static final boolean max(PdVector max,
                                        PdVector[] vecArr,
                                        int arrayLength)
        Find the maximum of an array of vectors in each component. Vectors of array may have different length. Any comparison is between the resulting vector and a vector of the array is done for the common number of components.
        Parameters:
        max - computed maximum
        vecArr - array of vectors
        arrayLength - number of used vectors of array
        See Also:
        min(PdVector, PdVector [], int), max(PdVector)
        Version:
        18.12.00, 1.20 revised (kp) Bug removed, now compare against Double.NEGATIVE_INFINITY rather than Double.MIN_VALUE.
        08.09.00, 1.11 revised (kp) Check for vecArr.length==0.
        27.12.99, 1.10 revised (kp) Allow variable length of vectors in array.
      • min

        public 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. Vectors of different length are adjusted at all common components.
        Parameters:
        vec - comparison vector
        See Also:
        min(PdVector, PdVector [], int), max(PdVector)
        Version:
        21.07.05, 1.00 created (kp)
      • max

        public 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. Vectors of different length are adjusted at all common components.
        Parameters:
        vec - comparison vector
        See Also:
        max(PdVector, PdVector [], int), min(PdVector)
        Version:
        21.07.05, 1.00 created (kp)
      • setConstant

        public static void setConstant(PdVector[] vecArr,
                                       double aValue)
        Set all components of all vectors of an array to a constant.
        Version:
        08.09.00, 1.11 revised (kp) Check for vecArr.length==0.
        24.07.00, 1.10 revised (kp) Now call method in inner loop.
      • setConstant

        public static void setConstant(PdVector[] vecArr,
                                       double[] data)
        Set all vectors of an array equal to a given vector. All vectors of argument array must have same length.
        Version:
        08.09.00, 1.01 revised (kp) Check for vecArr.length==0.
        24.07.00, 1.00 created (kp) From setConstant(PdVector[],PdVector).
      • setConstant

        public static void setConstant(PdVector[] vecArr,
                                       PdVector aVector)
        Set all vectors of an array equal to a given vector. All vectors of argument array must have same length.
        Version:
        24.07.00, 1.10 revised (kp) No calls setConstant(PdVector[],int[]).
      • setConstant

        public static void setConstant(PdVector v,
                                       double aValue)
        Set all entries to a constant value.
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • setConstant

        public void setConstant(double aValue)
        Set all entries to a constant value.
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • getOrientation

        public static double getOrientation(PdVector[] v)
        Deprecated. since JavaView 2.92.000, use same method det().
        Compute orientation of a frame of n vectors in R^n.
        Returns:
        double determinant of vectors
      • det

        public static double det(PdVector[] v)
        Compute determinant of a frame of n vectors in R^n. This method allocates a temporary matrix and returns PdMatrix.det(). See det(PdVector, PdVector, PdVector) for a direct method.
        Returns:
        double determinant of vectors
        Version:
        14.08.03, 1.10 revised (kp) Renamed det() from getOrientation(), same method body.
      • det

        public static double det(PdVector v,
                                 PdVector w,
                                 PdVector t)
        Compute determinant of a frame of three vectors in R^3. No intermediate memory allocations. See det(PdVector []) for another method.
        Parameters:
        v - Vector in R3.
        w - Vector in R3.
        t - Vector in R3.
        Returns:
        double determinant of vectors
        Since:
        JavaView 2.92.000
        Version:
        14.08.03, 1.00 created (kp)
      • 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)).
        Version:
        14.06.00, 1.10 revised (ep) Remove the argument p of the warning message.
      • angle

        public static double angle(PdVector p,
                                   PdVector q,
                                   PdVector r)
        Compute angle of triangle (p, q, r) at vertex p. The Result will be in the range (0.,180.).
        Version:
        25.11.2008, 1.00 created (fk) Inlined angle(v, w) to avoid PdVector allocation.
      • angle

        public static void angle(double[] angle,
                                 PdVector p,
                                 PdVector q,
                                 PdVector r)
        Compute interior angles at all three vertices of a triangle. Angle values will be in the range (0, pi).
      • angle

        public static void angle(double[] angle,
                                 PdVector[] p)
        Compute interior angles at all vertices of a convex polygon. Angle values will be in the range (0, pi).
      • angleWithOrientation

        public static double angleWithOrientation(double[] angle,
                                                  PdVector[] p,
                                                  int len)
        Compute exterior angles in radians 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(<v,w>). 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 in radians.
        Version:
        18.03.04, 2.50 revised (kp) Bug in sign computation of angle removed.
        10.02.01, 2.00 revised (kp) Remove dependency on normal.
      • angle

        public static double angle(PdVector v,
                                   PdVector w)
        Compute angle between two vectors in (0.,180.). All vectors must have same but arbitrary dimension.
        Returns:
        angle in (0.,180.), or 0. in case of error.
        Version:
        04.12.07, 1.10 revised (fk) Compute less square roots.
      • angleWithOrientation

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

        public static double dot(PdVector v,
                                 PdVector w)
        Scalar product of two given vectors.
        Parameters:
        v - vector
        w - vector
        Returns:
        scalar product
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • dot

        public 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.
        Parameters:
        p - base point
        q - end point of vector with base p
        r - end point of vector with base p
        Returns:
        scalar product
        Since:
        JavaView 2.46
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
        17.11.02, 1.00 created (kp)
      • dotDir

        public static double dotDir(PdVector v,
                                    PdVector q,
                                    PdVector p)
        Scalar product of two vectors v and w:=q-p determined by given vertices.
        Parameters:
        v - first vector
        q - end point of second vector with base p
        p - base point of second vector with end q
        Returns:
        scalar product
        Since:
        JavaView 3.97.058
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
        24.03.07, 1.00 created (kp)
      • sqrDist

        public static double sqrDist(PdVector v,
                                     PdVector w)
        Square of the distance of two points.
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • dist

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

        public static PdVector flatten(PdVector[] data)
        Flatten out array of vectors. The returned vector contains the entries of all vectors of the input array.
        Parameters:
        data - array of vectors
        Returns:
        new vector containing the entries of all vectors of the input array
        Version:
        25.07.07 1.00 created (kh)
      • flatten

        public static PdVector flatten(PdVector[] data,
                                       PdVector flat)
        Flatten out an array of vectors. The returned vector contains the entries of all vectors of the input array.
        Parameters:
        data - array of vectors
        flat - vector is returned, if argument is null a vector is created
        Returns:
        vector containing the entries of all vectors of the input array
        Version:
        25.07.07 1.00 created (kh)
      • 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:
        aSize - 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.
        Parameters:
        ind - index of component.
        value - new value of component.
        Version:
        29.09.99, 1.10 revised (kp) Check for m_data==null. 13.09.99, 1.10 revised (kp) setSize allocated one entry too few.
      • setEntry

        public void setEntry(int ind,
                             int value)
        Assign value to component of vector, and possibly enlarge vector if too small.
        Parameters:
        ind - index of component.
        value - new value of component.
        See Also:
        setEntry(int, double)
        Version:
        21.07.00 created (kp).
      • 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
        Version:
        25.07.00 revised (kp) 25.07.00 created (kp)
      • 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
        Version:
        25.07.00 revised (kp) 25.07.00 created (kp)
      • addEntry

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

        public void removeEntry(int ind)
        Remove an entry from the vector. All successive entries will be copied.
        Parameters:
        ind - Index of the entry to remove.
        Author:
        Matthias Nieser
        Version:
        16.03.10, 1.00 created (mn)
      • concat

        public void concat(PdVector pdv)
        Concatenates another PdVector to the end of this vector.
        Parameters:
        pdv - Vector to append to this one.
        Version:
        07.08.07, 1.00 created (mn)
      • 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.
        Version:
        22.12.99, 1.00 created (kp)
      • 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.
        Version:
        22.12.99 created (kp)
      • 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.
        Version:
        22.12.99 revised (kp) Method now just calls set(double[], int, int).
        29.09.99 revised (kp) Check for m_data==null.
      • set

        public void set(double[] x)
        Assign values of double array to vector, and adjust length of vector if different from length of array.
        Version:
        22.12.99 revised (kp) Method now just calls set(double[], int, int).
        29.09.99 revised (kp) Check for m_data==null.
      • 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)
        Version:
        21.07.00 created (kp).
      • 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)
        Version:
        21.07.00 created (kp).
      • 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 [])
        Version:
        21.07.00 created (kp).
      • set

        public void set(double x)
        Assign value to vector, and increase size of vector if necessary.
        Version:
        29.09.99 revised (kp) Check for m_data==null.
      • set

        public void set(double x,
                        double y)
        Assign value to vector, and increase size of vector if necessary.
        Version:
        29.09.99 revised (kp) Check for m_data==null.
      • set

        public void set(double x,
                        double y,
                        double z)
        Assign value to vector, and increase size of vector if necessary.
        Version:
        29.09.99 revised (kp) Check for m_data==null.
      • set

        public void set(double x,
                        double y,
                        double z,
                        double w)
        Assign value to vector, and increase size of vector if necessary.
        Version:
        29.09.99 revised (kp) Check for m_data==null.
      • 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.
        Returns:
        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)
        Returns:
        number of changed positions
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • shift

        public void shift(int num)
        Shift components in cyclic order within the array.
        Parameters:
        num - Number of positions each component is shifted.
        See Also:
        invert()
        Version:
        18.06.06, 1.00 created (mn) Copied from PiVector.shift().
      • 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)
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • add

        public void add(double val)
        Add argument to each component of vector.
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • add

        public void add(PdVector m)
        Sum with argument vector this += m. Both must be of same size.
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • add

        public void add(PdVector m1,
                        PdVector m2)
        Sum of argument vectors this = m1+m2. m1, m2 and this must be of same size.
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • sub

        public void sub(PdVector m)
        Difference with argument vector this = this-m. Vectors m and this must be of same size.
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • sub

        public void sub(PdVector m1,
                        PdVector m2)
        Difference of argument vectors this = m1-m2. Vectors must be of same size.
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • addNew

        public static PdVector addNew(PdVector m1,
                                      PdVector m2)
        Create a new vector as sum of argument vectors new = m1+m2.
        Version:
        04.03.01, 1.00 created (kp)
      • subNew

        public static PdVector subNew(PdVector m1,
                                      PdVector m2)
        Create a new vector as difference of argument vectors new = m1-m2. If sizes differ then a warning is thrown and a vector of minimal common size returned.
        Version:
        05.12.00, 1.10 revised (kp) Better check of array bounds.
      • copyNew

        public static PdVector copyNew(PdVector v)
        Create a new vector as clone of argument vector.
        Parameters:
        v - source vector to clone
        Version:
        29.04.06, 1.20 revised (kp) No longer throws a warning if arg is null.
        20.05.01, 1.10 revised (kp) Copy items of superclass too.
      • copy

        public 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.
        See Also:
        copy(PdVector)
        Version:
        26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
      • 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 minimum 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)
        Version:
        26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
        25.08.99, 1.05 revised (ur) Set size if 'this' is empty.
      • 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 minimum 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)
        Version:
        30.12.01, 1.10 revised (kp) Resize not only when m_data==null but also m_data.length==0.
        01.01.01, 1.00 revised (kp)
      • copyArray_fastTmp

        public void copyArray_fastTmp(PdVector v)
      • copy

        public void copy(double[] anArray,
                         int aSize)
        Copy a double array into a vector, and do not adjust size of a non-zero-length 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 minimum 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)
        Version:
        04.02.05, 1.20 revised (kp) Better sync with copy(PdVector).
        26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
        25.08.99, 1.05 revised (ur) Set size if 'this' is empty.
      • 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 a non-zero-length 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 minimum 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
        aSize - number of entries to copy.
        See Also:
        copy(double [], int)
        Version:
        19.06.15, 1.11 revised (kp) Number of member accesses reduced.
        26.12.99, 1.10 revised (kp) Use System.arraycopy internally.
      • multScalar

        public void multScalar(double scalar)
        Multiply vector with scalar this = scalar*this.
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • multScalar

        public void multScalar(PdVector v,
                               double scalar)
        Multiply argument vector with scalar this = scalar*v. Vectors v and this must be of same size.
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • leftMultMatrix

        public PdVector 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'!
        Returns:
        this vector
        Version:
        12.03.06, 1.10 revised (kp) Used clone instead of allocate/assign.
      • leftMultAffin

        public void leftMultAffin(PdMatrix m,
                                  PdVector v,
                                  boolean bPoint)
        Multiply a point resp. vector with matrix 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.
        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
        Version:
        28.07.03, 1.20 revised (kp) Matrix must be equal or larger than (this.length,v.length+1).
        23.07.03, 1.10 revised (kp) Size constraints of matrix now compare to this vector.
      • leftMultMatrix

        public PdVector 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.
        Returns:
        this
      • 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!
        Version:
        12.03.06, 1.10 revised (kp) Used clone instead of allocate/assign.
      • 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. Vectors must be of same size.
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • sqrLength

        public double sqrLength()
        Get square of Euclidean length of vector.
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • length

        public double length()
        Get Euclidean length of vector.
        Version:
        29.04.01, 1.00 created (kp) From method body of #length().
      • length

        public static double length(int num,
                                    double[] data)
        Get Euclidean length of vector.
        Parameters:
        num - number of components to be used from data array
        data - array whose Euclidean length is returned
        Version:
        29.04.01, 1.00 created (kp) From method body of #length().
      • normalize

        public boolean normalize()
        Normalize vector to unit length. In case of error, for example, if length of vector is too small then return false and set the maximal coordinate to 1.
        Version:
        02.06.04, 1.20 revised (kp) Use setLength(1.).
        05.02.02, 1.10 revised (kp) Error handling changed.
      • normalize

        public boolean normalize(PdVector v)
        Set vector to normalized argument vector.
        Version:
        02.06.04, 1.10 revised (kp) Use normalize() on copied vector.
      • setLength

        public boolean setLength(double aLength)
        Set Euclidean length of vector. If current vector has zero length then the highest components is assigned the requested length.
        Version:
        02.06.04, 1.10 revised (kp) If current vector has zero length, assign highest coordinate.
      • 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:
        a - weight of first vector
        v - first vector
        b - weight of second vector
        w - second vector
        See Also:
        blendBase(PdVector, double, PdVector), blendNew(double, PdVector, double, PdVector)
        Author:
        Konrad Polthier
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
        16.09.98, 1.00 created (kp)
      • blend

        public void blend(double a,
                          PdVector u,
                          double b,
                          PdVector v,
                          double c,
                          PdVector w)
        Interpolate between three vectors with given weights. Uses 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.
        Parameters:
        a - weight of first vector
        u - first vector
        b - weight of second vector
        v - second vector
        c - weight of third vector
        w - third vector
        See Also:
        blendNew(double, PdVector, double, PdVector, double, PdVector)
        Author:
        Klaus Hildebrandt
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
        10.12.04, 1.00 created (kh)
      • blend

        public 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. Uses 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.
        Parameters:
        a - weight of first vector
        u - first vector
        b - weight of second vector
        v - second vector
        c - weight of third vector
        w - third vector
        d - weight of fourth vector
        x - fourth vector
        See Also:
        blendNew(double, PdVector, double, PdVector, double, PdVector, double, PdVector)
        Author:
        Matthias Nieser
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
        12.06.04, 1.00 created (mn) Moved to PdVector from PwProjection.
      • blendBase

        public void blendBase(PdVector u,
                              double b,
                              PdVector v)
        Interpolate between two vectors with given weights. Uses 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.
        Parameters:
        u - first vector
        b - weight of second vector
        v - second vector
        See Also:
        blend(double, PdVector, double, PdVector), blendNew(double, PdVector, double, PdVector)
        Author:
        Konrad Polthier
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
        16.09.98, 1.00 created (kp)
      • dist

        public double dist(PdVector v)
        Euclidean distance dist = |this-v|.
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • sqrDist

        public double sqrDist(PdVector v)
        Square of Euclidean distance sqrDist = |this-v|^2.
        Version:
        19.06.15, 1.01 revised (kp) Number of member accesses reduced.
      • max

        public double max()
        Find maximal value of component in vector.
        Returns:
        value of maximal component, or zero if empty vector.
        See Also:
        min(), indexOfMax(), indexOfAbsMax()
        Version:
        19.06.15, 1.11 revised (kp) Number of member accesses reduced.
        27.05.07, 1.10 revised (kp) Now return 0 if empty vector.
      • maxAbs

        public double maxAbs()
        Find maximal absolute value of component in vector.
        Returns:
        absolute value of maximal absolute component, or zero if empty vector.
        See Also:
        min(), indexOfMax(), indexOfAbsMax()
        Version:
        19.06.15, 1.11 revised (kp) Number of member accesses reduced.
        27.05.07, 1.10 revised (kp) Now return 0 if empty vector.
      • min

        public double min()
        Find minimal value of component in vector.
        Returns:
        value of minimal component, or zero if empty vector.
        See Also:
        max(), indexOfMin(), indexOfAbsMin()
        Version:
        27.05.07, 1.10 revised (kp) Now return 0 if empty vector.
        26.04.07, 1.01 revised (fk) Use POSITIVE_INFINITY instead of MAX_VALUE.
      • indexOfAbsMax

        public int indexOfAbsMax()
        Find component in vector with maximal absolute value. If the maximum is not unique, the smallest index among the maxima is returned.
        Returns:
        index of maximal absolute component, or -1 if empty vector.
        See Also:
        max(), indexOfMax()
        Version:
        27.08.08, 1.30 revised (kp) Now return 0 if all entries are 0.
        27.05.07, 1.20 revised (kp) Now return -1 if empty vector.
        06.04.03, 1.10 revised (kp) Bug removed which led to malfunctioning of method if negative entries.
      • indexOfAbsMin

        public int indexOfAbsMin()
        Find component in vector with minimal absolute value.
        Returns:
        index of minimal absolute component, or -1 if empty vector.
        See Also:
        min(), indexOfMin()
        Version:
        27.05.07, 1.10 revised (kp) Now return -1 if empty vector.
        26.04.07, 1.01 revised (fk) Use POSITIVE_INFINITY instead of MAX_VALUE.
      • indexOfMax

        public int indexOfMax()
        Find component in vector with maximal value.
        Returns:
        index of maximal component, or -1 if empty vector.
        See Also:
        indexOfAbsMax()
        Version:
        27.05.07, 1.20 revised (kp) Now return -1 if empty vector.
        18.12.00, 1.10 revised (kp) Bug removed, now compare against Double.NEGATIVE_INFINITY rather than Double.MIN_VALUE.
      • indexOfMin

        public int indexOfMin()
        Find component in vector with minimal value.
        Returns:
        index of minimal component, or -1 if empty vector.
        See Also:
        indexOfAbsMin()
        Version:
        27.05.07, 1.10 revised (kp) Now return -1 if empty vector.
        26.04.07, 1.01 revised (fk) Use POSITIVE_INFINITY instead of MAX_VALUE.
      • indexOfValueInOrdering

        public int indexOfValueInOrdering(double value)
        Computes the index i of the first entry of vector with v[i]<=value in logarithmic time. Vector must be sort by increasing values.
        Parameters:
        value - Find position of this value in order vector.
        Returns:
        Index of the first entry of vector with v[i]<=value or -1 if value is smaller than minimum value of vector.
        Version:
        27.02.04, 1.10 revised (kp) Moved from jvx.geom.PwReeb.
        00.07.02, 1.00 created (kh)
      • sum

        public double sum()
        Compute the sum of all entries.
        Author:
        Felix Kaelberer
        Version:
        22.05.07, 1.00 created (fk)
      • average

        public double average()
        Compute the average of all entries. Return 0 if this vector has no entries.
        Returns:
        Average of all entries if size is > 0, and 0 otherwise.
        Author:
        Felix Kaelberer
        Version:
        22.06.07, 1.10 revised (kp) Avoid duplicate call of getSize().
        22.05.07, 1.00 created (fk)
      • variance

        public double variance()
        Compute the variance of the entries of a PdVector. Return 0 if this vector has no entries.
        Author:
        Felix Kaelberer
        Version:
        24.02.10, 1.30 revised (fk) Finally return variance instead of standard deviation.
        29.06.07, 1.20 revised (fk) Rolled back to version 1.00.
        22.06.07, 1.10 revised (kp) Avoid call of getSize().
        22.05.07, 1.00 created (fk)
      • sort

        public PdVector sort(PdVector vecOut)
        Sort entries of this vector into argument vector by increasing size. If the size of this vector is small (currently < 10) then bubble sort is used to avoid memory allocations. For larger sizes PuMath.heapsort(int,int[],int[]) is used.

        If missing or has different size then this, then size of vecOut is adjusted.

        See Also:
        sort()
      • sort

        public void sort()
        Sort entries of this vector in place by increasing size. If the size of this vector is small (currently < 10) then bubble sort is used to avoid memory allocations. For larger sizes PuMath.heapsort(int,int[],int[]) is used.
        See Also:
        sort(PdVector)
      • cross

        public boolean cross(PdVector v,
                             PdVector w)
        Compute cross product of given argument vectors. Argument vectors may have different dimensions in {2,3}. Missing dimensions are considered to be zero.

        Dimension of 'this' must be 3.

        'this' may be one of the argument vectors.

        Parameters:
        v - vector of (possibly mixed) dimensions 2 or 3.
        w - vector of (possibly mixed) dimensions 2 or 3.
        Returns:
        false, if dimension of this or argument vectors wrong.
        See Also:
        crossNew(PdVector, PdVector)
        Version:
        19.07.06, 2.00 revised (kp) Argument may be "this".
      • crossNew

        public static PdVector crossNew(PdVector v,
                                        PdVector w)
        Create new vector with cross product of given argument vectors. Argument vectors may have different dimensions in {2,3}. Missing dimensions are considered to be zero.
        Parameters:
        v - w,v: two vectors of (possibly mixed) dimensions 2 or 3.
        w - w,v: two vectors of (possibly mixed) dimensions 2 or 3.
        Returns:
        new vector of dimension 3.
        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 - <v,e>e. This vector will be orthogonal to vector e, or the zero vector.
        Parameters:
        e - unit vector.
      • orthonormalize

        public void orthonormalize(PdVector e)
        Remove part of 'this' in direction of e, assume |e|=1, v = v - <v,e>e, and normalize v. This vector will be orthonormal to vector e, or the zero vector.
        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 - <v,e>e. Returned vector will be orthogonal to vector e, or the zero vector.
        Parameters:
        vCompl - result vector, may be this vector. If null then it will be allocated.
        e - unit vector.
        Returns:
        complement vector will be orthogonal to e, or the zero vector.
      • orthogonalPartWrtONB

        public 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
        Parameters:
        e1 - unit vector.
        e2 - unit vector.
        Returns:
        complement vector will be orthogonal to e1 and e2, or the zero vector.
      • projectOntoONB

        public 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
      • normalOfPlane

        public boolean normalOfPlane(PdVector p,
                                     PdVector q,
                                     PdVector r)
        Compute unit normal vector to a plane given by three points.
        Returns:
        false if cross product failed or normalization.
      • normalToVector

        public void normalToVector(PdVector v)
        Compute an arbitrary vector orthonormal to a given unit vector v, assume |v|==1. Adjust size of this vector to size of argument vector.
      • normalToVectorNew

        public static PdVector normalToVectorNew(PdVector v)
        Create a new arbitrary vector orthogonal to a given unit vector.
      • 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(java.lang.Object obj)
        Determines whether another vector or array of doubles is equal to this vector.
        Overrides:
        equals in class java.lang.Object
        Since:
        JavaView 3.62.012
        See Also:
        equals(double[]), equals(PdVector), Object.equals(java.lang.Object)
      • equals

        public boolean equals(PdVector v)
        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:
        v - the vector to compare with
        Returns:
        true if the objects are the same; false otherwise.
      • equals

        public boolean equals(PdVector v,
                              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:
        v - the vector to compare with
        eps - distance for equality check
        Returns:
        true if the objects are the same; false otherwise.
      • lesser

        public boolean lesser(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 first vector has smaller 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.
        Since:
        JavaView 4.00.022
        Version:
        01.04.13, 1.00 created (kp)
      • lesser

        public boolean lesser(PdVector v)
        Determines whether another vector is lesser to this vector. The result is true if both vectors have same length and first vector has smaller components. Result is also true if argument vector is null and this vector has no entries.
        Parameters:
        v - the vector to compare with
        Returns:
        true if the objects are the same; false otherwise.
        Since:
        JavaView 4.00.022
        Version:
        01.04.13, 1.00 created (kp)
      • 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()
        Version:
        03.06.06, 1.10 revised (kp) Print empty brackets instead of null if empty data array.
      • toShortString

        public java.lang.String toShortString()
        Create a single-line string representation of the vector components and attributes.
        See Also:
        toString()
        Version:
        03.06.06, 1.10 revised (kp) Print empty brackets instead of null if empty data array.
      • removeSuccessiveDuplicates

        public void removeSuccessiveDuplicates()
        Removes all successive duplicate entries. Call sort() before, if you want to remove all duplicates.
        Author:
        Matthias Nieser
        Version:
        05.03.08, 1.00 created (mn)
"JavaView? v5.03.003"

"

The software JavaView? is copyright protected. All Rights Reserved.
"

You see the box below because you did not login.