public class TransformMesh extends Object implements InvertibleCoordinateTransform
See an example to find out how the mesh is constructed:
numX = 4; numY = 3:
*---*---*---* |\ / \ / \ /| | *---*---* | |/ \ / \ / \| *---*---*---* |\ / \ / \ /| | *---*---* | |/ \ / \ / \| *---*---*---*
Each vertex is given as a PointMatch
with
p1
being the original point and
p2
being the transferred point. Keep in mind
that Points store local and world coordinates with local coordinates being
constant and world coordinates being mutable. That is initially
p1.l
= p1.w
=
p2.l
while p1.w
is the transferred
location of the vertex.
Three adjacent vertices span a triangle. All pixels inside a triangle will
be transferred by a 2d affine transform
that is
defined by the three vertices. Given the abovementioned definition of a
vertex as PointMatch, this 2d affine transform
is a
forward transform (p1.l->p2.w)
.
Modifier and Type | Field and Description |
---|---|
protected HashMap<AffineModel2D,ArrayList<PointMatch>> |
av |
protected static PointFactory<Point> |
defaultPointFactory |
protected static PointMatchFactory<PointMatch> |
defaultPointMatchFactory |
protected double |
height |
protected HashMap<PointMatch,ArrayList<AffineModel2D>> |
va |
protected double |
width |
Modifier | Constructor and Description |
---|---|
|
TransformMesh(int numX,
double width,
double height) |
|
TransformMesh(int numX,
int numY,
double width,
double height) |
protected |
TransformMesh(int numX,
int numY,
double width,
double height,
PointFactory<?> pointFactory,
PointMatchFactory<?> pointMatchFactory) |
Modifier and Type | Method and Description |
---|---|
void |
addTriangle(ArrayList<PointMatch> t)
Add a triangle defined by 3 PointMatches that defines an
AffineTransform2D.
|
double[] |
apply(double[] location)
Apply the
CoordinateTransform to a location. |
void |
applyInPlace(double[] location)
Apply the
CoordinateTransform to a location. |
double[] |
applyInverse(double[] location)
Apply the inverse of the model to a point location
|
void |
applyInverseInPlace(double[] location)
apply the inverse of the model to a point location
|
void |
bounds(double[] min,
double[] max)
Calculate bounding box
|
TransformMesh |
createInverse()
TODO Not yet tested
|
PointMatch |
findClosestSourcePoint(double[] there)
Find the closest source point to a given coordinate.
|
PointMatch |
findClosestTargetPoint(double[] there)
Find the closest target point to a given coordinate.
|
HashMap<AffineModel2D,ArrayList<PointMatch>> |
getAV() |
double |
getHeight() |
HashMap<PointMatch,ArrayList<AffineModel2D>> |
getVA() |
double |
getWidth() |
String |
illustrateBestRigidSVG()
Create an SVG path that illustrates the best regid approximation of the
mesh as a rotated square.
|
Shape |
illustrateMesh()
Create a Shape that illustrates the mesh.
|
String |
illustrateMeshSVG()
Create an SVG path that illustrates the mesh.
|
protected void |
illustrateTriangle(AffineModel2D ai,
GeneralPath path) |
void |
init(CoordinateTransform t)
Initialize the mesh with a
CoordinateTransform . |
static boolean |
isInConvexTargetPolygon(ArrayList<PointMatch> pm,
double[] t)
Checks if a location is inside a given polygon at the target side or not.
|
static boolean |
isInSourcePolygon(ArrayList<PointMatch> pm,
double[] t)
Checks if a location is inside a given polygon at the source side or not.
|
protected static int |
numY(int numX,
double width,
double height) |
void |
scale(double scale)
Scale all vertex coordinates
|
void |
updateAffine(PointMatch p)
Update all affine transformations that would have been affected by a
given
Vertex . |
void |
updateAffines()
Update all affine transformations.
|
protected final double width
protected final double height
protected final HashMap<AffineModel2D,ArrayList<PointMatch>> av
protected final HashMap<PointMatch,ArrayList<AffineModel2D>> va
protected static final PointFactory<Point> defaultPointFactory
protected static final PointMatchFactory<PointMatch> defaultPointMatchFactory
protected TransformMesh(int numX, int numY, double width, double height, PointFactory<?> pointFactory, PointMatchFactory<?> pointMatchFactory)
public TransformMesh(int numX, int numY, double width, double height)
public TransformMesh(int numX, double width, double height)
public double getWidth()
public double getHeight()
public HashMap<AffineModel2D,ArrayList<PointMatch>> getAV()
public HashMap<PointMatch,ArrayList<AffineModel2D>> getVA()
protected static final int numY(int numX, double width, double height)
public void addTriangle(ArrayList<PointMatch> t)
t
- 3 PointMatches (will not be copied, so do not reuse this
list!)protected void illustrateTriangle(AffineModel2D ai, GeneralPath path)
public Shape illustrateMesh()
public String illustrateMeshSVG()
public String illustrateBestRigidSVG()
public void updateAffine(PointMatch p)
Vertex
.p
- public void updateAffines()
public PointMatch findClosestSourcePoint(double[] there)
PointMatch
, the source
coordinates are the local coordinates of the
source point.there
- PointMatch
in terms of the
source pointpublic PointMatch findClosestTargetPoint(double[] there)
PointMatch
, the target
coordinates are the world coordinates of the
target point.there
- PointMatch
in terms of the
target pointpublic static boolean isInConvexTargetPolygon(ArrayList<PointMatch> pm, double[] t)
pm
- t
- public static final boolean isInSourcePolygon(ArrayList<PointMatch> pm, double[] t)
pm
- t
- public double[] apply(double[] location)
CoordinateTransform
CoordinateTransform
to a location.apply
in interface CoordinateTransform
public void applyInPlace(double[] location)
CoordinateTransform
CoordinateTransform
to a location.applyInPlace
in interface CoordinateTransform
public double[] applyInverse(double[] location) throws NoninvertibleModelException
InverseCoordinateTransform
applyInverse
in interface InverseCoordinateTransform
NoninvertibleModelException
public void applyInverseInPlace(double[] location) throws NoninvertibleModelException
InverseCoordinateTransform
applyInverseInPlace
in interface InverseCoordinateTransform
NoninvertibleModelException
public TransformMesh createInverse()
createInverse
in interface InvertibleCoordinateTransform
public void init(CoordinateTransform t)
CoordinateTransform
.t
- public void scale(double scale)
scale
- public void bounds(double[] min, double[] max)
min
- max
- Copyright © 2015–2021 Fiji. All rights reserved.