jv.vecmath

## Class PdBary

- java.lang.Object
- - jv.vecmath.P_Vector
  - - jv.vecmath.PdBary

- All Implemented Interfaces:
    java.io.Serializable

      public class PdBary
      extends P_Vector

  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

- - ### 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

    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 jv.vecmath.P_Vector

      `clearTag, clone, clone, copy, getBits, getDetail, getName, getURL, hasTag, invert, setDetail, setName, setTag, setURL`

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

    - #### 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)`

    - #### 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)`

    - #### 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
           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)`

    - #### sqrDist

          public static double sqrDist(PdBary v,
                       PdBary w)

      Square of the distance of two points.
      Since:
        JavaView 3.05.004

    - #### dist

          public static double dist(PdBary v,
                    PdBary w)

      Distance of two points.
      Since:
        JavaView 3.05.004

    - #### toString

          public java.lang.String toString()

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

    - #### toShortString

          public java.lang.String toShortString()

      Create a single-line string representation of the vector components and attributes.
      See Also:
        `toString()`

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

    - #### setEntry

          public void setEntry(int ind,
                      double value)

      Assign value to component of vector, and possibly enlarge vector if too small.

    - #### set

          public void set(double x,
                 double y)

      Assign value to vector, and increase size of vector if necessary.

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

    - #### set

          public void set(double x,
                 double y,
                 double z)

      Assign value to vector, and increase size of vector if necessary.

    - #### set

          public void set(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.

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

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

    - #### 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)`

    - #### 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)`

    - #### 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)`

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

    - #### 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()`

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

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

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

    - #### 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()`

    - #### 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()`

    - #### 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,
                           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.

    - #### 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

    - #### 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)`

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

    - #### getBary

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

    - #### 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

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

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

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

"

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