jv.vecmath
Class PdBaryDir
- java.lang.Object
-
- jv.vecmath.P_Vector
-
- jv.vecmath.PdBaryDir
-
- All Implemented Interfaces:
- java.io.Serializable
public class PdBaryDir extends P_Vector
Barycentric tangent vector of arbitrary dimension, sum of entries must be 0. Internal array length is equal to barycentric dimension.- See Also:
- Serialized Form
- Author:
- Konrad Polthier
- Version:
- 23.08.06, 1.70 revised (mn) Added new instance variable m_elementInd.
08.07.06, 1.60 revised (kp) Method clone() implemented to replace copyNew() when used by subclasses.
20.02.03, 1.50 revised (ep) Methods getBaryDir/getVector return their result also as function value.
05.02.03, 1.40 revised (ep) New methodsgetBaryDir.
08.11.00, 1.30 revised (kp) Replace string formatting routines of Fmt with PuString.
28.08.00, 1.20 revised (ep) Method sub(PdBary,PdBary) added.
13.07.99, 1.10 revised (ep) Method multScalar() added.
09.06.99, 1.00 created (kp)
-
-
Field Summary
Fields Modifier and Type Field and Description double[]m_dataArray with barycentric coordinates, sum of entries must be 1.static PdBaryDir[]TRIANGLE_EDGEPositive oriented edges.
-
Constructor Summary
Constructors 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(PdBaryDir dir)Add two vectorsthis = this+dir.static PdBaryDir[][]alloc(int sizeI, int sizeJ, int vectorSize)Allocate a new array of vectors, where all vectors have the same dimension.voidblend(double a, PdBaryDir v, double b, PdBaryDir w)Interpolate between two vectors with given weights.voidblendBase(PdBaryDir v, double b, PdBaryDir w)Interpolate between two vectors with given weights.java.lang.Objectclone()Clone object and all instance variables.voidcopy(PdBaryDir vec)Copies argument vector into 'this', and possibly adjusts size of 'this'.voidcopyArray(PdBaryDir vec)Copies only data (no flags) of argument vector into 'this', and possibly adjusts size of 'this'.static PdBaryDircopyNew(PdBaryDir v)Create a new vector as clone of argument vector.static PdBaryDirgetBaryDir(PdBaryDir baryout, PdVector dir, PdVector v0, PdVector v1, PdVector v2)Get barycentric direction in triangle given by points.static PdBaryDirgetBaryDir(PdBaryDir baryout, PdVector dir, PdVector v0, PdVector v1, PdVector v2, PdVector temp)Get barycentric direction in triangle given by points.intgetElementInd()Get the element index to which the barycentric coordinates refer.intgetSize()Get dimension of barycentric vector.static PdVectorgetVector(PdVector p, PdBaryDir bary, PdVector v0, PdVector v1, PdVector v2)Get vector from barycentric direction in a triangle.voidleftMultMatrix(PdMatrix m)Multiply vector with matrixthis = m*this.voidleftMultMatrix(PdMatrix m, PdBaryDir v)Multiply vector with matrixthis = m*v.voidmultScalar(double scalar)Multiply all components with scalar.voidmultScalar(PdBaryDir v, double scalar)Multiply argument vector with scalarthis = scalar*v.static PdBaryDir[]realloc(PdBaryDir[] data, int arraySize, int vectorSize)Allocate an array of baryDir vectors, where all vectors have the same dimension.voidsetElementInd(int ind)Get the element index to which the barycentric coordinates refer.intsetSize(int aSize)Set dimension of barycentric vector, i.e. length of its data array.voidsetZero()Set all entries to a constant zero value.voidsub(PdBary m1, PdBary m2)Difference of argument vectorsthis = m1-m2.java.lang.StringtoShortString()Create a single-line string representation of the vector components and attributes.java.lang.StringtoString()Create a multi-line string representation with detailed information about all instance variables.voidvalidate()Check sum of barycentric coordinates, and adjust if sum is not zero.
-
-
-
Field Detail
-
TRIANGLE_EDGE
public static final PdBaryDir[] TRIANGLE_EDGE
Positive oriented edges. Index is the local index of opposite vertex to edge.
-
m_data
public double[] m_data
Array with barycentric coordinates, sum of entries must be 1. Length is equal to barycentric dimension.
-
-
Constructor Detail
-
PdBaryDir
public PdBaryDir()
Construct empty class with zero size.- Version:
- 27.12.01, 1.10 revised (kp) Now allocate array with zero length.
-
PdBaryDir
public PdBaryDir(int aSize)
Construct class with given dimension.
-
PdBaryDir
public PdBaryDir(double x, double y)Construct class with dimension=2 and given initial values.
-
PdBaryDir
public PdBaryDir(double x, double y, double z)Construct class with dimension=3 and given initial values.
-
PdBaryDir
public PdBaryDir(double x, double y, double z, double w)Construct class with dimension=4 and given initial values.
-
-
Method Detail
-
alloc
public static PdBaryDir[][] 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 arraysizeJ- number of columns in row[i] in new arrayvectorSize- dimension of vectors in new array- See Also:
realloc(PdBaryDir [], int, int)- Version:
- 27.11.06, 1.00 revised (kp)
-
realloc
public static PdBaryDir[] realloc(PdBaryDir[] data, int arraySize, int vectorSize)
Allocate an array of baryDir vectors, where all vectors have the same dimension. If argumentdata!=nullthen 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 vectorsarraySize- number of vectors in new arrayvectorSize- dimension of vectors in new array- See Also:
PdVector.realloc(PdVector [], int, int)- Version:
- 29.09.99 created (kp) From same method of PdVector.
-
setZero
public void setZero()
Set all entries to a constant zero value.
-
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:
- 24.12.06 created (mn)
-
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:
- 24.12.06 created (mn)
-
toString
public java.lang.String toString()
Create a multi-line string representation with detailed information about all instance variables.- Overrides:
toStringin classP_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()
-
clone
public java.lang.Object clone()
Clone object and all instance variables. Similar likecopyNew(PdBaryDir)but this clone() method is consistent with possible subclasses while copyNew() explicitly creates a new PdBaryDir.- Overrides:
clonein classP_Vector- See Also:
copyNew(PdBaryDir)- Version:
- 08.07.06, 2.00 revised (kp) Now explicitly use superclass.clone().
05.07.00, 1.00 created (kp)
-
copyNew
public static PdBaryDir copyNew(PdBaryDir v)
Create a new vector as clone of argument vector.- Parameters:
v- source vector to clone
-
copy
public void copy(PdBaryDir vec)
Copies argument vector into 'this', and possibly adjusts size of 'this'.- Parameters:
vec- the vector to be copied
-
copyArray
public void copyArray(PdBaryDir vec)
Copies only data (no flags) of 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, PdBaryDir v, double b, PdBaryDir w)Interpolate between two vectors with given weights. Usesthis = 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 vectorv- first vectorb- weight of second vectorw- second vector- See Also:
blendBase(PdBaryDir, double, PdBaryDir)- Author:
- Konrad Polthier
- Version:
- 23.10.05, 1.00 created (kp) Converted from PdVector method.
-
blendBase
public void blendBase(PdBaryDir v, double b, PdBaryDir w)
Interpolate between two vectors with given weights. Usesthis = 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 vectorw- second vectorb- weight of second vector- See Also:
blend(double, PdBaryDir, double, PdBaryDir)- 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 zero.
-
multScalar
public void multScalar(PdBaryDir v, double scalar)
Multiply argument vector with scalarthis = scalar*v. Vectors v and this must be of same size.- Version:
- 12.03.06, 1.00 created (kp)
-
multScalar
public void multScalar(double scalar)
Multiply all components with scalar.
-
leftMultMatrix
public void leftMultMatrix(PdMatrix m)
Multiply vector with matrixthis = m*this. Matrix must be square and of same size than vector. Method does not change size of 'this'!- Parameters:
m- a matrix- Version:
- 12.03.06, 1.00 created (kp)
-
leftMultMatrix
public void leftMultMatrix(PdMatrix m, PdBaryDir v)
Multiply vector with matrixthis = 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.
-
getVector
public static PdVector getVector(PdVector p, PdBaryDir bary, PdVector v0, PdVector v1, PdVector v2)
Get vector from barycentric direction in a triangle.- Parameters:
p- output, may be null; a new vector is returned in this case- Returns:
- World-representation of
bary. Same aspif that is notnull.
-
getBaryDir
public static PdBaryDir getBaryDir(PdBaryDir baryout, PdVector dir, PdVector v0, PdVector v1, PdVector v2)
Get barycentric direction in triangle given by points.- Parameters:
baryout- output, may be null; a new barycentric vector is returned in this case- Returns:
- Barycentric representation of
dir. Same asbaryoutif that is notnull. - Since:
- JavaView 2.49.007
-
getBaryDir
public static PdBaryDir getBaryDir(PdBaryDir baryout, PdVector dir, PdVector v0, PdVector v1, PdVector v2, PdVector temp)
Get barycentric direction in triangle given by points.- Parameters:
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)- Returns:
- Barycentric representation of
dir. Same asbaryoutif that is notnull. - Since:
- JavaView 2.49.007
- Version:
- 11.11.04, 1.10 revised (kh) Method rewritten.
-
sub
public void sub(PdBary m1, PdBary m2)
Difference of argument vectorsthis = m1-m2. Vectors must be of same size. The elementIdx will be ignored.
-
add
public void add(PdBaryDir dir)
Add two vectorsthis = this+dir. Vectors must be of same size. The elementIdx will be ignored.
-
-
"