jvx.numeric
Class PnStraightestGeodesic
- java.lang.Object
-
- jvx.numeric.PnStraightestGeodesic
-
public class PnStraightestGeodesic extends java.lang.ObjectThe exponential map on a PgElementSet. This class is intended to be used when the exponential map is evaluated very often. The basic idea is to speed up the calculations by computing and saving the linear transformations (3x3 matrices) that rotate around an edge from one element into another. These edge transformations can be computed all at once, whensetGeometryis called, or only when needed.Example:
exp = new PnStraightestGeodesic(geom); exp.eval(inPoint, inDir, outPoint, outDir, outPoly); // turn around and go back outDir.multScalar(-1); exp.eval(outPoint, outDir, revOutPoint, revOutDir);NowinPointrepresents the same point asrevOutPoint. Point being: If the geometry boundary is reached,outDiris scaled down to preserve this invariant. In this case, inDir and revOutDir may represent vectors of different length.inPointandrevOutPointare not necessarily on the same triangle (see below), butoutPoly.getVertexBary(0)andrevOutPointare. Of course,outPointis the last point ofoutPoly.Barycentric coordinates are used to represent points and vectors. The geometry must be triangulated.
- Author:
- Andreas Haferburg
- Version:
- 11.01.07, 1.10 revised (ah) Error check in computeTransformation.
01.03.06, 1.00 created (ah) Rewrite ofPgPolygonOnElementSet.exp().
-
-
Field Summary
Fields Modifier and Type Field and Description static doubleBARYEPSDefault accuracy used at checks for zero in barycentric coordinates (used e.g. in exp(...)).doublem_epsThis accuracy is actually used for zero-checks in barycentric coordinates (used e.g. in exp(...)).
-
Constructor Summary
Constructors Constructor and Description PnStraightestGeodesic(PgElementSet geometry)Creates a new instance of PnStraightestGeodesic.PnStraightestGeodesic(PgElementSet geometry, boolean precompute)Creates a new instance of PnStraightestGeodesic.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description inteval(PdBary basePoint, PdBaryDir dir, PdBary outPoint)Evaluates the exponential map.inteval(PdBary basePoint, PdBaryDir dir, PdBary outPoint, PdBaryDir outDir)Evaluates the exponential map.inteval(PdBary base, PdBaryDir dir, PdBary outPoint, PdBaryDir outDir, PgPolygonOnElementSet outPoly)Evaluates the exponential map.inteval(PdBary basePoint, PdBaryDir dir, PgPolygonOnElementSet outPoly)Evaluates the exponential map.inteval(PdBary basePoint, PdBaryDir dir, PgPolygonOnElementSet outPoly, PdBaryDir outDir)Evaluates the exponential map.doublegetAccuracy()Returns the accuracy used when testing barycentric coordinates for zero.PgElementSetgetGeometry()Returns the underlying geometry.booleanisSavingMatrices()Returns whether the linear transformations that rotate from one element into its neighbor are saved in an array.voidsetAccuracy(double accuracy)Sets the accuracy used when testing a barycentric coordinate for zero.voidsetGeometry(PgElementSet geom)Sets the underlying geometry.voidsetSavingMatrices(boolean bStoreMatrices)Sets if the edge transformations should be stored for later use.
-
-
-
Field Detail
-
BARYEPS
public static double BARYEPS
Default accuracy used at checks for zero in barycentric coordinates (used e.g. in exp(...)).
-
m_eps
public double m_eps
This accuracy is actually used for zero-checks in barycentric coordinates (used e.g. in exp(...)).
-
-
Constructor Detail
-
PnStraightestGeodesic
public PnStraightestGeodesic(PgElementSet geometry)
Creates a new instance of PnStraightestGeodesic. Calls setGeometry.- Parameters:
geometry- The underlying geometry.
-
PnStraightestGeodesic
public PnStraightestGeodesic(PgElementSet geometry, boolean precompute)
Creates a new instance of PnStraightestGeodesic. Calls setGeometry.- Parameters:
geometry- The underlying geometry.precompute- Compute the 3x3-matrices that represent the rotations around edges of adjacent elements. For every edge, 2 matrices are computed.
-
-
Method Detail
-
eval
public int eval(PdBary basePoint, PdBaryDir dir, PdBary outPoint)
Evaluates the exponential map.- Parameters:
basePoint- The point defining the tangent space.dir- The input vector in tangent space at which the exponential map is evaluated.outPoint- The output point.- Returns:
- 1 if everything went normally, -1 if the base is invalid, 0 if the geometry boundary was reached.
-
eval
public int eval(PdBary basePoint, PdBaryDir dir, PdBary outPoint, PdBaryDir outDir)
Evaluates the exponential map.- Parameters:
basePoint- The point defining the tangent space.dir- The input vector in tangent space at which the exponential map is evaluated.outPoint- The output point.outDir- Parallel translation of dir.- Returns:
- 1 if everything went normally, -1 if the base is invalid, 0 if the geometry boundary was reached.
-
eval
public int eval(PdBary basePoint, PdBaryDir dir, PgPolygonOnElementSet outPoly, PdBaryDir outDir)
Evaluates the exponential map.- Parameters:
basePoint- The point defining the tangent space.dir- The input vector in tangent space at which the exponential map is evaluated.outDir- Parallel translation of dir.outPoly- Output geodesic.- Returns:
- 1 if everything went normally, -1 if the base is invalid, 0 if the geometry boundary was reached.
-
eval
public int eval(PdBary basePoint, PdBaryDir dir, PgPolygonOnElementSet outPoly)
Evaluates the exponential map.- Parameters:
basePoint- The point defining the tangent space.dir- The input vector in tangent space at which the exponential map is evaluated.outPoly- Output geodesic.- Returns:
- 1 if everything went normally, -1 if the base is invalid, 0 if the geometry boundary was reached.
-
eval
public int eval(PdBary base, PdBaryDir dir, PdBary outPoint, PdBaryDir outDir, PgPolygonOnElementSet outPoly)
Evaluates the exponential map. The last two points of outPoly are guaranteed to be on the same element, and two consecutive points will be on elements that are neighbors.
Normally,baseis the first point of the outPoly. However, in the special case wherebaseis on an edge or a vertex, anddirdoesn't point atbase's element,basewon't be included in the output, but only the representation in a triangledirpoints at.- Parameters:
base- The point defining the tangent space.dir- The input vector in tangent space at which the exponential map is evaluated.outPoint- The output point, may be null.outDir- Parallel translation of dir, may be null.outPoly- Output geodesic, may be null.- Returns:
- 1 if everything went normally, -1 if the base is invalid, 0 if the geometry boundary was reached.
- Version:
- 01.03.06, 1.01 (ah) Modify poly vertices directly to avoid copying.
-
setGeometry
public void setGeometry(PgElementSet geom)
Sets the underlying geometry. Computes the edge transformations if it was specified in the constructor.- Parameters:
geom- New underlying geometry, must be triangulated.
-
getGeometry
public PgElementSet getGeometry()
Returns the underlying geometry.- Returns:
- The underlying geometry.
-
getAccuracy
public double getAccuracy()
Returns the accuracy used when testing barycentric coordinates for zero.- Returns:
- the accuracy
-
setAccuracy
public void setAccuracy(double accuracy)
Sets the accuracy used when testing a barycentric coordinate for zero. In all methods of this class, a barycentric coordinate b is treated as zero, iffMath.abs(b)<m_accuracy- Parameters:
accuracy- Accuracy to be used.
-
isSavingMatrices
public boolean isSavingMatrices()
Returns whether the linear transformations that rotate from one element into its neighbor are saved in an array.- Returns:
- Edge transformations are saved.
-
setSavingMatrices
public void setSavingMatrices(boolean bStoreMatrices)
Sets if the edge transformations should be stored for later use.- Parameters:
bStoreMatrices- matrices are stored.
-
-
"