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

Class PdBary

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


    public class PdBary
    extends P_Vector
    implements java.lang.Cloneable
    Vector with barycentric coordinates of arbitrary dimension, sum of entries must be 1. Internal array length is equal to barycentric dimension.
    See Also:
    Serialized Form
    Author:
    Konrad Polthier
    Version:
    31.03.14, 1.90 revised (ur) PdBary now implements "cloneable".
    08.07.06, 1.80 revised (kp) Method clone() implemented to replace copyNew() when used by subclasses.
    15.04.06, 1.70 revised (kp) New method realloc() and version of copy().
    13.03.06, 1.60 revised (kp) New instance variable m_elementInd.
    20.02.03, 1.50 revised (ep) New method isOutside.
    21.11.02, 1.40 revised (ep) Reallocate arrays in getBary if they have wrong size.
    24.07.00, 1.30 revised (ep) Small speed optimizations in getBary.
    08.11.00, 1.20 revised (kp) Replace string formatting routines of Fmt with PuString.
    18.07.00, 1.10 revised (kp) Lot of checks for m_data==null added.
    23.09.99, 1.01 revised (ur) new method getBary(PdBary, PdVector, PdVector, PdVector) written. 09.06.99, 1.00 created (kp)
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      double[] m_data
      Array with barycentric coordinates, sum of entries must be 1.
      int m_elementInd
      May be used as the element of this point, defaults to -1.
      static PdBary TRIANGLE_CENTER
      Triangle midpoint.
      static PdBary TRIANGLE_MID
      Deprecated. 
      since 3.96.006, use TRIANGLE_CENTER instead.
      static PdBary[] TRIANGLE_VERTEX
      Vertices, enumerated like in triangle.
    • Constructor Summary

      Constructors 
      Constructor and Description
      PdBary()
      Construct empty class of zero size.
      PdBary(double x, double y)
      Construct class with dimension=2 and given initial values.
      PdBary(double x, double y, double z)
      Construct class with dimension=3 and given initial values.
      PdBary(double x, double y, double z, double w)
      Construct class with dimension=4 and given initial values.
      PdBary(int aSize)
      Construct class with given dimension and initialize to (1,0,..,0).
      PdBary(int elem, double x, double y, double z)
      Construct class with dimension=3 and given initial values.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method and Description
      void add(PdBaryDir dir)
      this = this + dir
      static void add(PdBary bary, double lambda, PdBaryDir dir, PdBary outbary)
      Computes outbary = bary+lambda*dir.
      void add(PdBary point, PdBaryDir vector)
      this = point + vector
      static PdBary[][] alloc(int sizeI, int sizeJ, int vectorSize)
      Allocate a new array of vectors, where all vectors have the same dimension.
      void blend(double a, PdBary v, double b, PdBary w)
      Interpolate between two vectors with given weights.
      void blendBase(PdBary v, double b, PdBaryDir w)
      Interpolate between two vectors with given weights.
      java.lang.Object clone()
      Clone object and all instance variables.
      void copy(PdBary vec)
      Copies argument vector into 'this', and possibly adjusts size of 'this'.
      static boolean copy(PdBary[] dataDest, int destInd, PdBary[] dataSrc, int srcInd, int size)
      Copies some bary vectors of a given array of bary vectors into an existing destination array.
      static PdBary copyNew(PdBary v)
      Create a new vector as clone of argument vector.
      static double dist(PdBary v, PdBary w)
      Distance of two points.
      static void getBary(PdBary bary, PdVector p, PdVector[] v)
      Get barycentric coordinates of a point in the plane of a triangle in R^n.
      static boolean getBary(PdBary bary, PdVector p, PdVector v0, PdVector v1)
      Get barycentric coordinates of a point in an interval of a line in R^n.
      static void getBary(PdBary bary, PdVector p, PdVector v0, PdVector v1, PdVector v2)
      Get barycentric coordinates of a point in the plane of a triangle in R^n.
      static void getBaryInside(PdBary bary, PdVector p, PdVector[] v)
      Get barycentric coordinates of the closest point inside a triangle for a given point in R^n.
      int getElementInd()
      Get the element index to which the barycentric coordinates refer.
      double[] getEntries()
      Return a copy of content of vector as array of doubles.
      double getEntry(int ind)
      Get the component of a barycentric vector.
      int getFirstVertexOfEdge()
      Get local index of first vertex of edge.
      int getSecondVertexOfEdge()
      Get local index of second vertex of edge.
      int getSize()
      Get dimension of barycentric vector.
      static void getVertex(PdVector p, PdBary bary, PdVector v0, PdVector v1, PdVector v2)
      Deprecated. 
      in JavaView 3.97.040, use PdVector getVertex(PdVector p, PdVector v0, PdVector v1, PdVector v2).
      PdVector getVertex(PdVector p, PdVector v0, PdVector v1)
      Get vertex from barycentric coordinates of an edge.
      PdVector getVertex(PdVector p, PdVector v0, PdVector v1, PdVector v2)
      Get vertex from barycentric coordinates of a triangle.
      PdVector getVertex(PdVector p, PdVector v0, PdVector v1, PdVector v2, PdVector v3)
      Get vertex from barycentric coordinates of an edge.
      boolean isInside()
      Check whether point is inside, i.e. all barycentric coordinates are non-negative.
      boolean isInside(double eps)
      Check whether point is inside, i.e. all barycentric coordinates are > -eps.
      int isOnEdge()
      Get local edge index if bary is a vertex on an edge.
      int isOnEdge(double eps)
      Get local edge index if bary is a vertex on an edge, elsewise -1 is returned.
      int isOnFace()
      Get local edge resp. face index if bary is a vertex on an edge resp. face.
      int isOnFace(double eps)
      Get local edge resp. face index if bary is a vertex on an edge resp. face.
      int isOnVertex()
      Get local vertex index in {0, 1, 2, ...} if bary represents a vertex, or -1.
      int isOnVertex(double eps)
      Get local vertex index in {0, 1, 2, ...} if bary represents a vertex, or -1.
      int isOutside()
      Check whether point is outside, i.e. at least one barycentric coordinate is negative.
      int isOutside(double eps)
      Check whether point is outside, i.e. at least one barycentric coordinate is negative.
      void leftMultMatrix(PdMatrix m)
      Multiply vector with matrix this = m*this.
      void leftMultMatrix(PdMatrix m, PdBary v)
      Multiply vector with matrix this = m*v.
      void projectToInside()
      If the barycentric coordinates lie outside the simplex, they will be projected to the nearest point on the boundary of the simplex.
      static PdBary[] realloc(PdBary[] data, int arraySize, int vectorSize)
      Allocate an array of bary vectors, where all vectors have the same dimension.
      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(int elemInd, double x, double y)
      Assign value to vector, and increase size of vector if necessary.
      void set(int elemInd, double x, double y, double z)
      Assign value to vector, and increase size of vector if necessary.
      void setElementInd(int ind)
      Get the element index to which the barycentric coordinates refer.
      void setEntry(int ind, double value)
      Assign value to component of vector, and possibly enlarge vector if too small.
      int setSize(int aSize)
      Set dimension of barycentric vector, i.e. length of its data array.
      static double sqrDist(PdBary v, PdBary w)
      Square of the distance of two points.
      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.
      void validate()
      Check sum of barycentric coordinates, and adjust if sum is not one.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • TRIANGLE_VERTEX

        public static final PdBary[] TRIANGLE_VERTEX
        Vertices, enumerated like in triangle.
      • TRIANGLE_CENTER

        public static final PdBary TRIANGLE_CENTER
        Triangle midpoint.
      • TRIANGLE_MID

        public static final PdBary TRIANGLE_MID
        Deprecated. since 3.96.006, use TRIANGLE_CENTER instead.
        Triangle midpoint.
      • m_data

        public double[] m_data
        Array with barycentric coordinates, sum of entries must be 1. Length is equal to barycentric dimension.
      • m_elementInd

        public int m_elementInd
        May be used as the element of this point, defaults to -1.
    • Constructor Detail

      • PdBary

        public PdBary()
        Construct empty class of zero size.
        Version:
        27.12.01, 1.10 revised (kp) Now allocate array with zero length.
      • PdBary

        public PdBary(int aSize)
        Construct class with given dimension and initialize to (1,0,..,0).
      • PdBary

        public PdBary(double x,
                      double y)
        Construct class with dimension=2 and given initial values.
      • PdBary

        public PdBary(double x,
                      double y,
                      double z)
        Construct class with dimension=3 and given initial values.
      • PdBary

        public PdBary(int elem,
                      double x,
                      double y,
                      double z)
        Construct class with dimension=3 and given initial values.
      • PdBary

        public PdBary(double x,
                      double y,
                      double z,
                      double w)
        Construct class with dimension=4 and given initial values.
    • Method Detail

      • alloc

        public static PdBary[][] 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(PdBary [], int, int)
        Version:
        27.11.06, 1.00 revised (kp)
      • realloc

        public static PdBary[] realloc(PdBary[] data,
                                       int arraySize,
                                       int vectorSize)
        Allocate an array of bary 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:
        PdVector.realloc(PdVector [], int, int)
        Version:
        16.04.06 created (kp) From same method of PdVector.
      • copy

        public static boolean copy(PdBary[] dataDest,
                                   int destInd,
                                   PdBary[] dataSrc,
                                   int srcInd,
                                   int size)
        Copies some bary vectors of a given array of bary vectors into an existing destination array. All bary 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 bary vectors
        destInd - index of first destination bary vector in dataDest
        dataSrc - source array of bary vectors
        srcInd - index of first source bary vector in dataSrc used for copying
        size - number of copied bary vectors of array
        Returns:
        true if destination array is large enough
        See Also:
        PdVector.copy(PdVector [], int, PdVector [], int, int), copy(PdBary)
        Version:
        16.04.06 created (kp) From same method of PdVector.
      • sqrDist

        public static double sqrDist(PdBary v,
                                     PdBary w)
        Square of the distance of two points.
        Since:
        JavaView 3.05.004
        Version:
        22.10.05, 1.00 created (kp)
      • dist

        public static double dist(PdBary v,
                                  PdBary w)
        Distance of two points.
        Since:
        JavaView 3.05.004
        Version:
        22.10.05, 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 (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 (kp) Print empty brackets instead of null if empty data array.
      • getEntries

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

        public double getEntry(int ind)
        Get the component of a barycentric vector.
        Version:
        29.09.99 created (kp) From same method of PdVector.
      • setEntry

        public void setEntry(int ind,
                             double value)
        Assign value to component of vector, and possibly enlarge vector if too small.
        Version:
        29.09.99 created (kp) From same method of PdVector.
      • set

        public void set(double x,
                        double y)
        Assign value to vector, and increase size of vector if necessary.
        Version:
        16.04.06 created (kp)
      • set

        public void set(int elemInd,
                        double x,
                        double y)
        Assign value to vector, and increase size of vector if necessary.
        Parameters:
        elemInd - Index of this element to which the barycentric coordinates refer.
        Version:
        16.04.06 created (kp)
      • set

        public void set(double x,
                        double y,
                        double z)
        Assign value to vector, and increase size of vector if necessary.
        Version:
        16.04.06 created (kp)
      • set

        public void set(int elemInd,
                        double x,
                        double y,
                        double z)
        Assign value to vector, and increase size of vector if necessary.
        Parameters:
        elemInd - Index of this element to which the barycentric coordinates refer.
        Version:
        16.04.06 created (kp)
      • getElementInd

        public int getElementInd()
        Get the element index to which the barycentric coordinates refer.
        Returns:
        Index of this element to which the barycentric coordinates refer.
        Version:
        16.04.06 created (kp)
      • setElementInd

        public void setElementInd(int ind)
        Get the element index to which the barycentric coordinates refer.
        Parameters:
        ind - Index of this element to which the barycentric coordinates refer.
        Version:
        16.04.06 created (kp)
      • clone

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

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

        public void copy(PdBary vec)
        Copies argument vector into 'this', and possibly adjusts size of 'this'.
        Parameters:
        vec - the vector to be copied
      • getSize

        public int getSize()
        Get dimension of barycentric vector.
      • setSize

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

        public void blend(double a,
                          PdBary v,
                          double b,
                          PdBary 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(PdBary, double, PdBaryDir)
        Author:
        Konrad Polthier
        Version:
        23.10.05, 1.00 created (kp) Converted from PdVector method.
      • blendBase

        public void blendBase(PdBary v,
                              double b,
                              PdBaryDir 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 second vector
        See Also:
        blend(double, PdBary, double, PdBary)
        Author:
        Konrad Polthier
        Version:
        23.10.05, 1.00 created (kp) Converted from PdVector method.
      • validate

        public void validate()
        Check sum of barycentric coordinates, and adjust if sum is not one. If sum of barycentric coordinate is different from 1. by more than PuMath#EPS then vector is normalized.
        Version:
        18.07.99, 1.10 revised (kp) Do not normalize if close to 1, also slight tuning.
      • projectToInside

        public void projectToInside()
        If the barycentric coordinates lie outside the simplex, they will be projected to the nearest point on the boundary of the simplex.
        See Also:
        validate()
        Author:
        Matthias Nieser
        Version:
        26.11.06, 1.30 revised (kp) Method made non-static.
        26.11.06, 1.20 revised (mn) Method now works for any simplex with dimension != 3.
        18.10.06, 1.10 revised (mn) Moved to PdBary.
      • isInside

        public boolean isInside()
        Check whether point is inside, i.e. all barycentric coordinates are non-negative.
      • isInside

        public boolean isInside(double eps)
        Check whether point is inside, i.e. all barycentric coordinates are > -eps.
        Version:
        08.09.06, 1.10 created (mn) Added epsilon tolerance.
      • isOutside

        public int isOutside()
        Check whether point is outside, i.e. at least one barycentric coordinate is negative. Method returns index of first negative entry (i.e. vertex index opposite to edge where point lies behind) or -1 if point is not outside.
        Since:
        JavaView 2.51.000
      • isOutside

        public int isOutside(double eps)
        Check whether point is outside, i.e. at least one barycentric coordinate is negative. Method returns index of first entry which is < eps (i.e. vertex index opposite to edge where point lies behind) or -1 if point is not outside.
        Version:
        08.09.06, 1.10 created (mn) Added epsilon tolerance.
      • isOnVertex

        public int isOnVertex()
        Get local vertex index in {0, 1, 2, ...} if bary represents a vertex, or -1.
      • isOnVertex

        public int isOnVertex(double eps)
        Get local vertex index in {0, 1, 2, ...} if bary represents a vertex, or -1.
        Version:
        08.09.06, 1.10 created (mn) Added epsilon tolerance.
      • isOnEdge

        public int isOnEdge()
        Get local edge index if bary is a vertex on an edge. For triangles, the local edge index is equal to the local index of the opposite vertex. For tetrahedra, and higher dimensional simplices, the answer is just boolean encoded as true = 1 or false = -1. For 1 dimensional barycentric coordinates, the answer is 1 if the point lies inside, else it is -1.
        See Also:
        isOnFace()
      • isOnEdge

        public int isOnEdge(double eps)
        Get local edge index if bary is a vertex on an edge, elsewise -1 is returned. For triangles, the local edge index is equal to the local index of the opposite vertex. For tetrahedra, and higher dimensional simplices, the answer is just boolean encoded as true = 1 or false = -1. For 1 dimensional barycentric coordinates, the answer is 1 if the point lies inside, else it is -1.
        See Also:
        isOnFace()
        Version:
        08.09.06, 1.10 created (mn) Added epsilon tolerance.
        19.10.06, 2.00 revised (mn) Added check isInside() for higher dimensions.
      • isOnFace

        public int isOnFace()
        Get local edge resp. face index if bary is a vertex on an edge resp. face. For triangles, the local edge index is equal to the index of the opposite vertex. For higher dimensional simplices, the local index represents a simplex face and is equal to the local index of the vertex opposite to the face. For triangles, method is performs identical to isOnEdge() which should be used instead for better readability. For dimension==2, method is performs identical to isOnVertex() and returns the local index of the vertex, and not any 'opposite'.
        See Also:
        isOnVertex()
      • isOnFace

        public int isOnFace(double eps)
        Get local edge resp. face index if bary is a vertex on an edge resp. face. For triangles, the local edge index is equal to the index of the opposite vertex. For higher dimensional simplices, the local index represents a simplex face and is equal to the local index of the vertex opposite to the face. For triangles, method is performs identical to isOnEdge() which should be used instead for better readability. For dimension==2, method is performs identical to isOnVertex() and returns the local index of the vertex, and not any 'opposite'.
        See Also:
        isOnVertex()
        Version:
        08.09.06, 1.10 created (mn) Added epsilon tolerance.
      • getVertex

        public static void getVertex(PdVector p,
                                     PdBary bary,
                                     PdVector v0,
                                     PdVector v1,
                                     PdVector v2)
        Deprecated. in JavaView 3.97.040, use PdVector getVertex(PdVector p, PdVector v0, PdVector v1, PdVector v2).
        Get vertex from barycentric coordinates of a triangle.
      • getVertex

        public PdVector getVertex(PdVector p,
                                  PdVector v0,
                                  PdVector v1)
        Get vertex from barycentric coordinates of an edge.
        Parameters:
        p - Assigned output vector, will be allocated if null.
        v0 - Start of the edge.
        v1 - Endpoint of the edge.
        Returns:
        argument output vector p, or a new vector if p was null.
        Since:
        JavaView 3.97.040
      • getVertex

        public PdVector getVertex(PdVector p,
                                  PdVector v0,
                                  PdVector v1,
                                  PdVector v2,
                                  PdVector v3)
        Get vertex from barycentric coordinates of an edge.
        Parameters:
        p - Assigned output vector, will be allocated if null.
        v0 - Start of the edge.
        v1 - Endpoint of the edge.
        Returns:
        argument output vector p, or a new vector if p was null.
        Version:
        11.01.11, 1.00 created (mn)
      • add

        public void add(PdBaryDir dir)
        this = this + dir
      • add

        public void add(PdBary point,
                        PdBaryDir vector)
        this = point + vector
      • add

        public static void add(PdBary bary,
                               double lambda,
                               PdBaryDir dir,
                               PdBary outbary)
        Computes outbary = bary+lambda*dir.
        Parameters:
        bary - barycentric base point
        lambda - factor
        dir - barycentric direction (in same element as barycentric base point)
        outbary - result
        Version:
        23.08.06, 1.30 revised (mn) Moved from PwBary.blendBase() to PdBary.add().
        16.02.05, 1.20 created (ep) Created from vgp.curve.subdivision.PjSubdivisionCurve.
      • 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'!

        Note, this method allocates a copy of this vector temporarily, therefore, try to use #leftMultMatrix(PdMatrix, PdBary) instead.

        Parameters:
        m - a matrix
        See Also:
        leftMultMatrix(PdMatrix, PdBary)
        Version:
        12.03.06, 1.00 created (kp)
      • leftMultMatrix

        public void leftMultMatrix(PdMatrix m,
                                   PdBary 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.
        Version:
        12.03.06, 1.00 created (kp) From similar method of PdVector.
      • getBary

        public static void getBary(PdBary bary,
                                   PdVector p,
                                   PdVector[] v)
        Get barycentric coordinates of a point in the plane of a triangle in R^n.
        Since:
        JavaView 3.95.006
        Version:
        03.11.05, 1.00 created (kp) Moved from getBary(PdBary, PdVector, PdVector, PdVector, PdVector).
      • getBaryInside

        public static void getBaryInside(PdBary bary,
                                         PdVector p,
                                         PdVector[] v)
        Get barycentric coordinates of the closest point inside a triangle for a given point in R^n.
        Author:
        Ulrich Reitebuch
        Version:
        17.12.10, 1.00 created (ur)
      • getBary

        public static boolean getBary(PdBary bary,
                                      PdVector p,
                                      PdVector v0,
                                      PdVector v1)
        Get barycentric coordinates of a point in an interval of a line in R^n.
        Returns:
        False if v0 and v1 do not span a line.
        Version:
        17.10.07, 3.00 revised (mn) Add boolean return value.
        16.11.02, 2.00 revised (kp) All internal allocation removed.
        18.07.00, 1.10 revised (kp) Internal allocation removed.
      • getFirstVertexOfEdge

        public int getFirstVertexOfEdge()
        Get local index of first vertex of edge. For triangles, the first index is defined assuming the edges are oriented [0, 1], [1, 2], and [2, 0]. For higher dimensional simplices, just either of the two vertex indices is return. If vertex does not lie on an edge, -1 is returned.
      • getSecondVertexOfEdge

        public int getSecondVertexOfEdge()
        Get local index of second vertex of edge. For triangles, the second index is defined assuming the edges are oriented [0, 1], [1, 2], and [2, 0]. For higher dimensional simplices, just either of the two vertex indices is return. If vertex does not lie on an edge, -1 is returned.
"JavaView? v5.03.003"

"

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

Ads help maintain this website.