public class PdBary extends P_Vector
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 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.
|
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.
|
public static final PdBary[] TRIANGLE_VERTEX
public static final PdBary TRIANGLE_CENTER
public static final PdBary TRIANGLE_MID
public double[] m_data
public int m_elementInd
public PdBary()
public PdBary(int aSize)
public PdBary(double x, double y)
public PdBary(double x, double y, double z)
public PdBary(int elem, double x, double y, double z)
public PdBary(double x, double y, double z, double w)
public static PdBary[][] alloc(int sizeI, int sizeJ, int vectorSize)
sizeI
- number of rows in new arraysizeJ
- number of columns in row[i] in new arrayvectorSize
- dimension of vectors in new arrayrealloc(PdBary [], int, int)
public static PdBary[] realloc(PdBary[] data, int arraySize, int vectorSize)
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.
data
- possibly empty array of vectorsarraySize
- number of vectors in new arrayvectorSize
- dimension of vectors in new arrayPdVector.realloc(PdVector [], int, int)
public static boolean copy(PdBary[] dataDest, int destInd, PdBary[] dataSrc, int srcInd, int size)
for (int i=0; iDestination array must be large enough, i.e. dataDest.length >= destInd+size
.
dataDest
- destination array of bary vectorsdestInd
- index of first destination bary vector in dataDestdataSrc
- source array of bary vectorssrcInd
- index of first source bary vector in dataSrc used for copyingsize
- number of copied bary vectors of arraytrue
if destination array is large enoughPdVector.copy(PdVector [], int, PdVector [], int, int)
,
copy(PdBary)
public static double sqrDist(PdBary v, PdBary w)
public java.lang.String toString()
toString
in class P_Vector
toShortString()
public java.lang.String toShortString()
toString()
public double[] getEntries()
public double getEntry(int ind)
public void setEntry(int ind, double value)
public void set(double x, double y)
public void set(int elemInd, double x, double y)
elemInd
- Index of this element to which the barycentric coordinates refer.public void set(double x, double y, double z)
public void set(int elemInd, double x, double y, double z)
elemInd
- Index of this element to which the barycentric coordinates refer.public int getElementInd()
public void setElementInd(int ind)
ind
- Index of this element to which the barycentric coordinates refer.public java.lang.Object clone()
copyNew(PdBary)
but this clone() method is consistent with possible subclasses
while copyNew() explicitly creates a new PdBary.clone
in class java.lang.Object
copyNew(PdBary)
public static PdBary copyNew(PdBary v)
v
- source vector to clonepublic void copy(PdBary vec)
vec
- the vector to be copiedpublic int getSize()
public int setSize(int aSize)
aSize
- new number of components of vectorpublic void blend(double a, PdBary v, double b, PdBary w)
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.a
- weight of first vectorv
- first vectorb
- weight of second vectorw
- second vectorblendBase(PdBary, double, PdBaryDir)
public void blendBase(PdBary v, double b, PdBaryDir w)
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.v
- first vectorw
- second vectorb
- weight of second vectorblend(double, PdBary, double, PdBary)
public void validate()
PuMath#EPS
then vector is normalized.public void projectToInside()
validate()
public boolean isInside()
public boolean isInside(double eps)
public int isOutside()
public int isOutside(double eps)
public int isOnVertex()
public int isOnVertex(double eps)
public int isOnEdge()
true = 1
or false = -1
.
For 1 dimensional barycentric coordinates, the answer is 1 if the point lies
inside, else it is -1.isOnFace()
public int isOnEdge(double eps)
true = 1
or false = -1
.
For 1 dimensional barycentric coordinates, the answer is 1 if the point lies
inside, else it is -1.isOnFace()
public int isOnFace()
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'.isOnVertex()
public int isOnFace(double eps)
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'.isOnVertex()
public static void getVertex(PdVector p, PdBary bary, PdVector v0, PdVector v1, PdVector v2)
public PdVector getVertex(PdVector p, PdVector v0, PdVector v1, PdVector v2)
public PdVector getVertex(PdVector p, PdVector v0, PdVector v1)
p
- Assigned output vector, will be allocated if null.v0
- Start of the edge.v1
- Endpoint of the edge.public PdVector getVertex(PdVector p, PdVector v0, PdVector v1, PdVector v2, PdVector v3)
p
- Assigned output vector, will be allocated if null.v0
- Start of the edge.v1
- Endpoint of the edge.public void add(PdBaryDir dir)
public static void add(PdBary bary, double lambda, PdBaryDir dir, PdBary outbary)
outbary = bary+lambda*dir
.bary
- barycentric base pointlambda
- factordir
- barycentric direction (in same element as barycentric base point)outbary
- resultpublic void leftMultMatrix(PdMatrix m)
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.
m
- a matrixleftMultMatrix(PdMatrix, PdBary)
public void leftMultMatrix(PdMatrix m, PdBary v)
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.public static void getBary(PdBary bary, PdVector p, PdVector v0, PdVector v1, PdVector v2)
public static void getBary(PdBary bary, PdVector p, PdVector[] v)
public static void getBaryInside(PdBary bary, PdVector p, PdVector[] v)
public static boolean getBary(PdBary bary, PdVector p, PdVector v0, PdVector v1)
public int getFirstVertexOfEdge()
public int getSecondVertexOfEdge()
"