JavaView© v3.95.000

jvx.geom
Class PwBary

java.lang.Object
  extended byjvx.geom.PwBary

public final class PwBary
extends java.lang.Object

Static methods that handle barycentric coordinates on triangulated element sets.


Constructor Summary
PwBary()
           
 
Method Summary
static void blendBase(PdBary bary, double lambda, PdBaryDir dir, PdBary outbary)
          Computes outbary = bary+lambda*dir.
static void changeBarycentricOnEdge(PdBary inOut, int locind1, int locind2)
          Switch to barycentric coordinates that represent same point on edge wrt the other element adjacent to edge.
static double computeLambda(PdBary pos, PdBaryDir dir)
          Computes the smallest positive solution of 'pos + lambda*dir lies on boundary' for lambda.
static PdBaryDir[] computeNormals(PgPolygonOnElementSet poly, PdBaryDir[] normals, PiVector elementind)
          TODO: DOES NOT WORK WITH CLOSED POLYGONS YET!
static int createVectorAtVertexThatShowsIntoElement(PgElementSet geom, int iniElem, PdBary iniBary, PdBaryDir iniDir)
           
static int equalizeElementIndex(PgPolygonOnElementSet poly, int index1, int index2, PdBary out1, PdBary out2)
          Outputs the coordinates of two vertices on a barycentric polygon such that their barycentric coordinates refer to the same element.
static int getEdgeIndex(PdBary pos)
          Checks for first occurrence of zero (i.e. |.|< eps) in the barycentric vector.
static PdBaryDir[] getGeodRepresentation(PgElementSet geom, int origElem, PdBaryDir origDir, int localvertexindex, PiVector elements, PiVector localind)
          Calculates the representations of a given vector in all elements of a vertex star by completion to a unnormalized angle of theta/2.
static double getOrientedAngle(PgElementSet geom, int elemInd, PdBaryDir a, PdBaryDir b, boolean recalc)
          Oriented angle between two barycentric vectors in a triangle.
static double getOrientedAngleAtEdge(PgElementSet geom, int elemind1, PdBaryDir dir1, int localedgeind1, int elemind2, PdBaryDir dir2, int localedgeind2, boolean recalc)
           
static double getOrientedAngleAtVertex(PgElementSet geom, int elemind1, PdBaryDir dir1, int localvertind1, int elemind2, PdBaryDir dir2, int localvertind2, boolean recalc)
          Computes the normalized angle between two barycentric vectors based at the same vertex.
static PdBaryDir[] getProjRepresentation(PgElementSet geom, int origElem, PdBaryDir origDir, int localvertexindex, PiVector elements, PiVector locind)
          Calculates the representations of a given vector in all elements of a vertex star by projection onto the plane the element lays in.
static PdBaryDir[] getTransRepresentation(PgElementSet geom, int origElem, PdBaryDir origDir, int localvertexindex, PiVector elements, PiVector locind)
          Calculates the representations of a given vector in all elements of a vertex star by parallel translation along a straightest geodesic (half angles).
static double getTransRepresentationValues(PgElementSet geom, int origElem, PdBaryDir origDir, int localvertexindex, PiVector elements, PiVector locind, PdVector betas)
          Calculates the values (beta,theta) of a given vector in all elements of a vertex star by parallel translation along a straightest geodesic.
static double getVertexAngles(PgVertexStar star, PgElementSet geom, PdVector angles)
          Calculates inner angles of the elements of a vertexstar.
static int liesOnVertex(PdBary pos)
          Checks if given barycentric position lies on any vertex
static double norm(PgElementSet geom, int elemInd, PdBaryDir x, boolean bForceRecalc)
          Euklidian norm of two intrinsic (barycentric) vectors.
static void projectOntoElement(PgElementSet geom, int elemInd, PdVector dir, PdBaryDir outdir)
          Projects given vector onto elements plane.
static int rotateAtEdge(PgElementSet geom, int elem, PdBaryDir dir, int localedgeind, PdBaryDir out, PdBary pos, double angle, boolean recalc)
          Rotates a barycentric direction with base point on edge.
static int rotateAtVertex(PgElementSet geom, int elemind, int localvertexind, PdBaryDir dir, PdBaryDir outdir, PdBary bary, double angle)
          Rotates direction at vertex in same orientation as the star.
static void rotateInElement(PgElementSet geom, int elemInd, PdBaryDir dir, double angle, PdBaryDir outdir, boolean bForceRecalc)
          Rotates direction in same orientation as the element's.
static double scalar(PgElementSet geom, int elemInd, PdBaryDir x, PdBaryDir y, boolean bForceRecalc)
          Computes scalar product of barycentric directions in world coordinates, that means the scalar product of the vectors in euklidian space.
static boolean showsIntoElement(PdBaryDir dir, int vertexindex)
          Checks if given barycentric vector shows into it's element.
static boolean transformBary(PgElementSet geom, int origElem, PdBary origBary, int destElem, PdBary outBary)
          Tries to change a barycentric coordinate to the representation of the same space point wrt a different triangle.
static void translatePolygonOnElementSet(PgPolygonOnElementSet poly, PdBaryDir[] vf, PiVector vfInd, PdVector distField)
          Translates the vertices of the polygon a given distance into a given direction.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PwBary

public PwBary()
Method Detail

scalar

public static double scalar(PgElementSet geom,
                            int elemInd,
                            PdBaryDir x,
                            PdBaryDir y,
                            boolean bForceRecalc)
Computes scalar product of barycentric directions in world coordinates, that means the scalar product of the vectors in euklidian space. The directions have to live on the same element. If geometry and element index are the same as they were at previous call of scalar and parameter forceRecalc == false then some calculations are skipped.

Parameters:
geom - geometry the barycentric directions live on
elemInd - element the barycentric directions live on
x - one direction
y - other direction
bForceRecalc - if true all variables are forced two be recalculated; should only be used if the geometry may not be the same (in world coordinates) as in previous calls
Returns:
scalar product

norm

public static double norm(PgElementSet geom,
                          int elemInd,
                          PdBaryDir x,
                          boolean bForceRecalc)
Euklidian norm of two intrinsic (barycentric) vectors. Implemented as copy of the method PwBary.scalar(..) and additional square root.

Parameters:
geom - the geometry the barycentric direction lives on
elemInd - the element the barycentric direction lives on
x - barycentric vector
bForceRecalc - used for scalar product
Returns:
sqrt(< x,x > )
See Also:
scalar(jv.geom.PgElementSet, int, jv.vecmath.PdBaryDir, jv.vecmath.PdBaryDir, boolean)

getVertexAngles

public static double getVertexAngles(PgVertexStar star,
                                     PgElementSet geom,
                                     PdVector angles)
Calculates inner angles of the elements of a vertexstar. Only for triangulations. User has to ensure that star is already computed, and that geom and angles parameters are not null.

Parameters:
star - the star
geom - the geometry
angles - output: vertex angles of elements in star, in same order as PgVertexStar.getElement(). if necessary it is resized.
Returns:
sum of the angles

getGeodRepresentation

public static PdBaryDir[] getGeodRepresentation(PgElementSet geom,
                                                int origElem,
                                                PdBaryDir origDir,
                                                int localvertexindex,
                                                PiVector elements,
                                                PiVector localind)
Calculates the representations of a given vector in all elements of a vertex star by completion to a unnormalized angle of theta/2. Element set must be triangulated.

Parameters:
geom - triangulation
origElem - element in which the vector is given
origDir - vector that will be translated to the other elements
localvertexindex - local index in origElem of the vertex at which the vector is given
elements - output: global element indices of the vertex star
localind - output: local vertex indices of common vertex in elements at vertex star
Returns:
array of the calculated directions at success, null else

getTransRepresentation

public static PdBaryDir[] getTransRepresentation(PgElementSet geom,
                                                 int origElem,
                                                 PdBaryDir origDir,
                                                 int localvertexindex,
                                                 PiVector elements,
                                                 PiVector locind)
Calculates the representations of a given vector in all elements of a vertex star by parallel translation along a straightest geodesic (half angles). Element set must be triangulated.

Parameters:
geom - triangulation
origElem - element in which the vector is given
origDir - vector that will be translated to the other elements
localvertexindex - the local index in origElem of the vertex in which the vector is given
elements - output: global element indices of the vertex star
locind - output: local vertex indices of the vertex star
Returns:
array of the calculated directions at success, null else

getTransRepresentationValues

public static double getTransRepresentationValues(PgElementSet geom,
                                                  int origElem,
                                                  PdBaryDir origDir,
                                                  int localvertexindex,
                                                  PiVector elements,
                                                  PiVector locind,
                                                  PdVector betas)
Calculates the values (beta,theta) of a given vector in all elements of a vertex star by parallel translation along a straightest geodesic. Rotate counter-clockwise next edge by angleOfEvaluationPointToEdge - 2*PI/theta*(beta+angle), where angle is the angle between evaluation position and edge. Element set must be triangulated.

Parameters:
geom - set of elements
origElem - element in which the vector is given
origDir - vector that will be translated to the other elements
localvertexindex - the local index in origElem of the vertex in which the vector is given
elements - output: global element indices of the vertex star, beginning with origElem
locind - output: local indices of common vertex of star, beginning with localvertexindex
betas - output: beta values
Returns:
theta

getProjRepresentation

public static PdBaryDir[] getProjRepresentation(PgElementSet geom,
                                                int origElem,
                                                PdBaryDir origDir,
                                                int localvertexindex,
                                                PiVector elements,
                                                PiVector locind)
Calculates the representations of a given vector in all elements of a vertex star by projection onto the plane the element lays in. Element set must be triangulated.

Parameters:
geom - set of elements
origElem - element on which the vector is given
origDir - vector that will be translated to the other elements
localvertexindex - the local index in origElem of the vertex in which the vector is given
elements - output: global element indicee of the vertex star
locind - output: local vertex indices of the vertex star
Returns:
array of the calculated directions at success, null else

projectOntoElement

public static void projectOntoElement(PgElementSet geom,
                                      int elemInd,
                                      PdVector dir,
                                      PdBaryDir outdir)
Projects given vector onto elements plane.

Parameters:
geom - underlying geometry
elemInd - global element index
dir - in world coordinates
outdir - output: barycentric coordinates of the projected vector

getOrientedAngle

public static double getOrientedAngle(PgElementSet geom,
                                      int elemInd,
                                      PdBaryDir a,
                                      PdBaryDir b,
                                      boolean recalc)
Oriented angle between two barycentric vectors in a triangle. User has to ensure that geometry is not null, element index is valid, a and b are not null and have size 3.
THIS METHOD IS NOT THREAD SAFE! SIMULTANEOUS CALLS IN DIFFERENT THREADS MAY PRODUCE WEIRD RESULTS!

Parameters:
geom - underlying geometry
elemInd - global element index
a - first vector
b - second vector
recalc - used for scalar product
Returns:
oriented angle in [-PI, PI]; negative if a must be rotated against the orientation of the triangle; -3*PI if an error occurred
See Also:
scalar(jv.geom.PgElementSet, int, jv.vecmath.PdBaryDir, jv.vecmath.PdBaryDir, boolean)

getOrientedAngleAtVertex

public static double getOrientedAngleAtVertex(PgElementSet geom,
                                              int elemind1,
                                              PdBaryDir dir1,
                                              int localvertind1,
                                              int elemind2,
                                              PdBaryDir dir2,
                                              int localvertind2,
                                              boolean recalc)
Computes the normalized angle between two barycentric vectors based at the same vertex. (The angle that the first vector must be rotated around the vertex to become the second vertex.) If vertex star is closed, the angle is a positive angle. If the vertex star is NOT closed, the sign of the returned angle tells in which direction the first vector must be rotated such that it doesn't cross the boundary of the star.
The element indices of the two vectors must be different for this method! Use getOrientedAngle if this is not the case. Furthermore they must point into the element they lie on.
THIS METHOD IS NOT THREAD SAFE! SIMULTANEOUS CALLS IN DIFFERENT THREADS MAY PRODUCE WEIRD RESULTS!


getOrientedAngleAtEdge

public static double getOrientedAngleAtEdge(PgElementSet geom,
                                            int elemind1,
                                            PdBaryDir dir1,
                                            int localedgeind1,
                                            int elemind2,
                                            PdBaryDir dir2,
                                            int localedgeind2,
                                            boolean recalc)

rotateInElement

public static void rotateInElement(PgElementSet geom,
                                   int elemInd,
                                   PdBaryDir dir,
                                   double angle,
                                   PdBaryDir outdir,
                                   boolean bForceRecalc)
Rotates direction in same orientation as the element's.

Parameters:
geom - underlying geometry
elemInd - element on that vector lies
dir - barycentric direction
angle - rad
outdir - output: result of rotation; may be same instance as dir
bForceRecalc - used for scalar product
See Also:
scalar(jv.geom.PgElementSet, int, jv.vecmath.PdBaryDir, jv.vecmath.PdBaryDir, boolean)

rotateAtVertex

public static int rotateAtVertex(PgElementSet geom,
                                 int elemind,
                                 int localvertexind,
                                 PdBaryDir dir,
                                 PdBaryDir outdir,
                                 PdBary bary,
                                 double angle)
Rotates direction at vertex in same orientation as the star. An angle of 2*Pi means a complete turn around the star.

Parameters:
geom - underlying geometry
elemind - global element index
localvertexind - local index of vertex that is base of the rotation
dir - original vector
outdir - output: result of rotation
bary - output: barycentric coordinates of the base point of the result
angle - normalized angle [0;2*PI] ^= 360°
Returns:
global element index where outdir lies on, or -1 if either an error occurred or rotation would be outside of element set (if vertex star is not closed)

rotateAtEdge

public static int rotateAtEdge(PgElementSet geom,
                               int elem,
                               PdBaryDir dir,
                               int localedgeind,
                               PdBaryDir out,
                               PdBary pos,
                               double angle,
                               boolean recalc)
Rotates a barycentric direction with base point on edge.

Parameters:
geom - underlying triangulation
elem - element index of barycentric direction
dir - barycentric direction with base point on element edge (pointing into element)
localedgeind - local index in element of the edge the direction lies on
out - output: rotated barycentric direction
pos - input/output: base point is converted to new element if necessary
angle - in [0;2*PI]
Returns:
element index of output direction

showsIntoElement

public static boolean showsIntoElement(PdBaryDir dir,
                                       int vertexindex)
Checks if given barycentric vector shows into it's element.

Parameters:
dir - barycentric vector that shall be checked
vertexindex - local vertex index that is the base of the direction
Returns:
true if barycentric vector shows into it's element

liesOnVertex

public static int liesOnVertex(PdBary pos)
Checks if given barycentric position lies on any vertex

Parameters:
pos - barycentric point, must not be null
Returns:
localvertexindex if pos lays in PgPolygonOnElementSet#BARYEPS-sphere around any vertex;
-1 otherwise

computeLambda

public static double computeLambda(PdBary pos,
                                   PdBaryDir dir)
Computes the smallest positive solution of 'pos + lambda*dir lies on boundary' for lambda. You have to ensure that pos and dir have same size and are not null. pos has to lie inside the simplex.

Parameters:
pos - Must not be null. Must have same size as dir.
dir - Must not be null. Must have same size as pos.
Returns:
Double.POSITIVE_INFINITY if dir is zero and pos does not already lie on boundary.

getEdgeIndex

public static int getEdgeIndex(PdBary pos)
Checks for first occurrence of zero (i.e. |.|< eps) in the barycentric vector.

Parameters:
pos - must not be null
Returns:
-1 if point lies strictly inside or outside the simplex.

computeNormals

public static PdBaryDir[] computeNormals(PgPolygonOnElementSet poly,
                                         PdBaryDir[] normals,
                                         PiVector elementind)
TODO: DOES NOT WORK WITH CLOSED POLYGONS YET!


translatePolygonOnElementSet

public static void translatePolygonOnElementSet(PgPolygonOnElementSet poly,
                                                PdBaryDir[] vf,
                                                PiVector vfInd,
                                                PdVector distField)
Translates the vertices of the polygon a given distance into a given direction. Note: This will produce a polygon that does no longer fully lives on the element set, only the vertices still are somewhere on the element set. This makes the PolygonOnElementSet useless for most other methods that handle PolygonOnElementSets (that usually require a polygon vertex where the polygon crosses a geometry edge).

Parameters:
poly - polygon to translate
vf - normalized barycentric directions for each vertex of polygon
vfInd - element indices for the barycentric directions
distField - the distance to move for each polygon vertex

transformBary

public static boolean transformBary(PgElementSet geom,
                                    int origElem,
                                    PdBary origBary,
                                    int destElem,
                                    PdBary outBary)
Tries to change a barycentric coordinate to the representation of the same space point wrt a different triangle.


equalizeElementIndex

public static int equalizeElementIndex(PgPolygonOnElementSet poly,
                                       int index1,
                                       int index2,
                                       PdBary out1,
                                       PdBary out2)
Outputs the coordinates of two vertices on a barycentric polygon such that their barycentric coordinates refer to the same element.

Parameters:
poly - the polygon on a triangulation
index1 - first point (index in poly)
index2 - second point (index in poly)
Returns:
common element index or -1

changeBarycentricOnEdge

public static void changeBarycentricOnEdge(PdBary inOut,
                                           int locind1,
                                           int locind2)
Switch to barycentric coordinates that represent same point on edge wrt the other element adjacent to edge. Only triangles.

Parameters:
inOut - must have a zero at locind1, result is put here
locind1 - local index of edge in origin triangle
locind2 - local index of edge in destination triangle

blendBase

public static void blendBase(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

createVectorAtVertexThatShowsIntoElement

public static int createVectorAtVertexThatShowsIntoElement(PgElementSet geom,
                                                           int iniElem,
                                                           PdBary iniBary,
                                                           PdBaryDir iniDir)

JavaView© v3.95.000

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