JavaView® v2.12

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.

Version:
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)
Author:
Konrad Polthier
See Also:
Serialized Form

Field Summary
 double[] m_data
          Array with barycentric coordinates, sum of entries must be 1.
 
Constructor Summary
PdBary()
          Construct empty class.
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.
 
Method Summary
 java.lang.Object clone()
          Duplicate vector and data array.
 void copy(PdBary vec)
          Copies argument vector into 'this', and possibly adjusts size of 'this'.
static PdBary copyNew(PdBary v)
          Create a new vector as clone of argument vector.
static void 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.
 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)
          Get vertex from barycentric coordinates of a triangle.
 boolean isInside()
          Check whether point is inside, i.e. all barycentric coordinates are non-negative.
 int isOnEdge()
          Get local edge index if bary is a vertex on an edge.
 int isOnFace()
          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.
 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.
 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, getName, hasTag, setName, setTag
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_data

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

PdBary

public PdBary()
Construct empty class.

PdBary

public PdBary(int aSize)
Construct class with given dimension.

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(double x,
              double y,
              double z,
              double w)
Construct class with dimension=4 and given initial values.
Method Detail

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.

clone

public java.lang.Object clone()
Duplicate vector and data array. Method just returns result of copyNew(PdBary).
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:
new - number of components of vector
Returns:
new number of components of vector

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.

isInside

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

isOnVertex

public int isOnVertex()
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.
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()

getVertex

public static void getVertex(PdVector p,
                             PdBary bary,
                             PdVector v0,
                             PdVector v1,
                             PdVector v2)
Get vertex from barycentric coordinates of a triangle.

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 v0,
                           PdVector v1)
Get barycentric coordinates of a point in an interval of a line in R^n.

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® v2.12

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