public class PdBaryDir extends P_Vector
Modifier and Type | Field and Description |
---|---|
double[] |
m_data
Array with barycentric coordinates, sum of entries must be 1.
|
static PdBaryDir[] |
TRIANGLE_EDGE
Positive oriented edges.
|
Constructor and Description |
---|
PdBaryDir()
Construct empty class with zero size.
|
PdBaryDir(double x,
double y)
Construct class with dimension=2 and given initial values.
|
PdBaryDir(double x,
double y,
double z)
Construct class with dimension=3 and given initial values.
|
PdBaryDir(double x,
double y,
double z,
double w)
Construct class with dimension=4 and given initial values.
|
PdBaryDir(int aSize)
Construct class with given dimension.
|
Modifier and Type | Method and Description |
---|---|
void |
add(PdBaryDir dir)
Add two vectors
this = this+dir . |
static PdBaryDir[][] |
alloc(int sizeI,
int sizeJ,
int vectorSize)
Allocate a new array of vectors, where all vectors have the same dimension.
|
void |
blend(double a,
PdBaryDir v,
double b,
PdBaryDir w)
Interpolate between two vectors with given weights.
|
void |
blendBase(PdBaryDir v,
double b,
PdBaryDir w)
Interpolate between two vectors with given weights.
|
java.lang.Object |
clone()
Clone object and all instance variables.
|
void |
copy(PdBaryDir vec)
Copies argument vector into 'this', and possibly adjusts size of 'this'.
|
void |
copyArray(PdBaryDir vec)
Copies only data (no flags) of argument vector into 'this', and possibly adjusts size of 'this'.
|
static PdBaryDir |
copyNew(PdBaryDir v)
Create a new vector as clone of argument vector.
|
static PdBaryDir |
getBaryDir(PdBaryDir baryout,
PdVector dir,
PdVector v0,
PdVector v1,
PdVector v2)
Get barycentric direction in triangle given by points.
|
static PdBaryDir |
getBaryDir(PdBaryDir baryout,
PdVector dir,
PdVector v0,
PdVector v1,
PdVector v2,
PdVector temp)
Get barycentric direction in triangle given by points.
|
int |
getElementInd()
Get the element index to which the barycentric coordinates refer.
|
int |
getSize()
Get dimension of barycentric vector.
|
static PdVector |
getVector(PdVector p,
PdBaryDir bary,
PdVector v0,
PdVector v1,
PdVector v2)
Get vector from barycentric direction in a triangle.
|
void |
leftMultMatrix(PdMatrix m)
Multiply vector with matrix
this = m*this . |
void |
leftMultMatrix(PdMatrix m,
PdBaryDir v)
Multiply vector with matrix
this = m*v . |
void |
multScalar(double scalar)
Multiply all components with scalar.
|
void |
multScalar(PdBaryDir v,
double scalar)
Multiply argument vector with scalar
this = scalar*v . |
static PdBaryDir[] |
realloc(PdBaryDir[] data,
int arraySize,
int vectorSize)
Allocate an array of baryDir vectors, where all vectors have the same dimension.
|
void |
setElementInd(int ind)
Get the element index to which the barycentric coordinates refer.
|
int |
setSize(int aSize)
Set dimension of barycentric vector, i.e. length of its data array.
|
void |
setZero()
Set all entries to a constant zero value.
|
void |
sub(PdBary m1,
PdBary m2)
Difference of argument vectors
this = m1-m2 . |
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
with detailed information about all instance variables.
|
void |
validate()
Check sum of barycentric coordinates, and adjust if sum is not zero.
|
public static final PdBaryDir[] TRIANGLE_EDGE
public double[] m_data
public PdBaryDir()
public PdBaryDir(int aSize)
public PdBaryDir(double x, double y)
public PdBaryDir(double x, double y, double z)
public PdBaryDir(double x, double y, double z, double w)
public static PdBaryDir[][] 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(PdBaryDir [], int, int)
public static PdBaryDir[] realloc(PdBaryDir[] 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 void setZero()
public int getElementInd()
public void setElementInd(int ind)
ind
- Index of this element to which the barycentric coordinates refer.public java.lang.String toString()
toString
in class P_Vector
toShortString()
public java.lang.String toShortString()
toString()
public java.lang.Object clone()
copyNew(PdBaryDir)
but this clone() method is consistent with possible subclasses
while copyNew() explicitly creates a new PdBaryDir.clone
in class java.lang.Object
copyNew(PdBaryDir)
public static PdBaryDir copyNew(PdBaryDir v)
v
- source vector to clonepublic void copy(PdBaryDir vec)
vec
- the vector to be copiedpublic void copyArray(PdBaryDir 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, PdBaryDir v, double b, PdBaryDir 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(PdBaryDir, double, PdBaryDir)
public void blendBase(PdBaryDir 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, PdBaryDir, double, PdBaryDir)
public void validate()
public void multScalar(PdBaryDir v, double scalar)
this = scalar*v
.
Vectors v and this must be of same size.public void multScalar(double scalar)
public void leftMultMatrix(PdMatrix m)
this = m*this
.
Matrix must be square and of same size than vector.
Method does not change size of 'this'!m
- a matrixpublic void leftMultMatrix(PdMatrix m, PdBaryDir 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 PdVector getVector(PdVector p, PdBaryDir bary, PdVector v0, PdVector v1, PdVector v2)
p
- output, may be null; a new vector is returned in this casebary
. Same as p
if that is not null
.public static PdBaryDir getBaryDir(PdBaryDir baryout, PdVector dir, PdVector v0, PdVector v1, PdVector v2)
baryout
- output, may be null; a new barycentric vector is returned in this casedir
. Same as baryout
if that is not null
.public static PdBaryDir getBaryDir(PdBaryDir baryout, PdVector dir, PdVector v0, PdVector v1, PdVector v2, PdVector temp)
baryout
- may be null; a new barycentric vector is returned in this casetemp
- used as buffer, may be null (is allocated automatically in this case)dir
. Same as baryout
if that is not null
.public void sub(PdBary m1, PdBary m2)
this = m1-m2
.
Vectors must be of same size. The elementIdx will be ignored.public void add(PdBaryDir dir)
this = this+dir
.
Vectors must be of same size. The elementIdx will be ignored."