net.aerith.misao.util
Class TriangleMatchingSolver

java.lang.Object
  |
  +--net.aerith.misao.util.TriangleMatchingSolver

public class TriangleMatchingSolver
extends java.lang.Object

The TriangleMatchingSolver is a class to solve matching between two lists of (x,y) positions, based on the triangles pattern matching.


Inner Class Summary
protected  class TriangleMatchingSolver.TriangleMap
          The TriangleMap represents a map of triangles based on the ratio of edges.
protected  class TriangleMatchingSolver.TrianglePosition
          The TrianglePosition represents a triangle with function to get virtual (x,y) position on a TriangleMap.
protected  class TriangleMatchingSolver.TriGraph
          The TriGraph represents a graph which has function to create triangles from itself.
protected  class TriangleMatchingSolver.TriIndex
          The TriIndex represents a set of three indexes in the original list which expresses a triangle.
 
Field Summary
protected  double acceptable_ratio
          The upper limit of ratio of the map function to judge proper.
protected  double best_score
          The best score of the matching.
protected  double check_accuracy
          The accuracy to judge a mapped position coincides with a position in the other list when to check if the calculated map function is proper.
protected  PositionList checklist1
          The first list of (x,y) positions to check if the map function is proper.
protected  PositionList checklist2
          The second list of (x,y) positions to check if the map function is proper.
protected  PositionList list1
          The first list of (x,y) positions.
protected  PositionList list2
          The second list of (x,y) positions.
protected  MonitorSet monitor_set
          The set of monitors.
protected  double score_to_fail
          The score to fail.
protected  double score_to_pass
          The score to pass.
protected  int triangle_map_division_count
          The number to divide the map of triangles, which is divided into triangle_map_division_count x triangle_map_division_count parts.
protected  double triangle_map_unit_ratio
          The unit of ratio of the map of triangles, which must be greater than 1.0.
protected  int trigraph_search_step1
          The number of steps to create triangles from the graph of first (x,y) list.
protected  int trigraph_search_step2
          The number of steps to create triangles from the graph of second (x,y) list.
 
Constructor Summary
TriangleMatchingSolver(PositionList list1, PositionList list2)
          Constructs a TriangleMatchingSolver with two lists of (x,y) positions.
 
Method Summary
 void addMonitor(Monitor monitor)
          Adds a monitor.
 double getScore()
          Gets the matching score.
 void setAcceptableRatio(double ratio)
          Sets the upper limit of ratio of the map function to judge proper.
 void setCheckAccuracy(double accuracy)
          Sets the accuracy to judge a mapped position coincides with a position in the other list when to check if the calculated map function is proper.
 void setCheckList(PositionList list1, PositionList list2)
          Sets the first list of (x,y) positions to check if the map function is proper.
 void setScoreToFail(double score)
          Sets the score to fail.
 void setScoreToPass(double score)
          Sets the score to pass.
 void setTriangleMapDivisionParameters(int division_count, double unit_ratio)
          Sets the number to divide and the unit of ratio of the map of triangles.
 void setTriGraphSearchSteps(int step1, int step2)
          Sets the number of steps to create triangles from the two graphs of (x,y) lists.
 MapFunction solve()
          Solves matching between the specified lists of (x,y) positions and returns a MapFunction which converts (x,y) position in the first list to (x,y) position in the second list.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

list1

protected PositionList list1
The first list of (x,y) positions.

list2

protected PositionList list2
The second list of (x,y) positions.

checklist1

protected PositionList checklist1
The first list of (x,y) positions to check if the map function is proper.

checklist2

protected PositionList checklist2
The second list of (x,y) positions to check if the map function is proper.

monitor_set

protected MonitorSet monitor_set
The set of monitors.

trigraph_search_step1

protected int trigraph_search_step1
The number of steps to create triangles from the graph of first (x,y) list.

trigraph_search_step2

protected int trigraph_search_step2
The number of steps to create triangles from the graph of second (x,y) list.

triangle_map_division_count

protected int triangle_map_division_count
The number to divide the map of triangles, which is divided into triangle_map_division_count x triangle_map_division_count parts.

triangle_map_unit_ratio

protected double triangle_map_unit_ratio
The unit of ratio of the map of triangles, which must be greater than 1.0.

score_to_pass

protected double score_to_pass
The score to pass. When the score of the map function is greater than this value, it is judged as correct and returned immediately.

score_to_fail

protected double score_to_fail
The score to fail. When the score of the map function is less than this value after all trials finished, the matching process is judged as failed and MatchingFailedException is thrown.

acceptable_ratio

protected double acceptable_ratio
The upper limit of ratio of the map function to judge proper. If the ratio of the map function is between 1.0 / acceptable_ratio and acceptable_ratio, it is proper.

check_accuracy

protected double check_accuracy
The accuracy to judge a mapped position coincides with a position in the other list when to check if the calculated map function is proper. It will be the mesh size to divide the check list map.

best_score

protected double best_score
The best score of the matching.
Constructor Detail

TriangleMatchingSolver

public TriangleMatchingSolver(PositionList list1,
                              PositionList list2)
Constructs a TriangleMatchingSolver with two lists of (x,y) positions.
Parameters:
list1 - the first list of (x,y) positions.
list2 - the second list of (x,y) positions.
Method Detail

addMonitor

public void addMonitor(Monitor monitor)
Adds a monitor.
Parameters:
monitor - the monitor.

setCheckList

public void setCheckList(PositionList list1,
                         PositionList list2)
Sets the first list of (x,y) positions to check if the map function is proper.
Parameters:
list1 - the first list of (x,y).
list2 - the second list of (x,y).

setTriGraphSearchSteps

public void setTriGraphSearchSteps(int step1,
                                   int step2)
Sets the number of steps to create triangles from the two graphs of (x,y) lists.

setTriangleMapDivisionParameters

public void setTriangleMapDivisionParameters(int division_count,
                                             double unit_ratio)
                                      throws java.lang.IllegalArgumentException
Sets the number to divide and the unit of ratio of the map of triangles.

The map of triangles is divided into division_count x division_count parts. The unit of ratio must be greater than 1.0.

Parameters:
division_count - the number to divide this map.
unit_ratio - the unit of ratio to divide.
Throws:
java.lang.IllegalArgumentException - if the specified division count is not greater than 1.0.

setScoreToPass

public void setScoreToPass(double score)
Sets the score to pass. When the score of the map function is greater than this value, it is judged as correct and returned immediately.
Parameters:
score - the score to pass.

setScoreToFail

public void setScoreToFail(double score)
Sets the score to fail. When the score of the map function is less than this value after all trials finished, the matching process is judged as failed and MatchingFailedException is thrown.
Parameters:
score - the score to fail.

setAcceptableRatio

public void setAcceptableRatio(double ratio)
Sets the upper limit of ratio of the map function to judge proper.
Parameters:
ratio - the acceptable ratio.

setCheckAccuracy

public void setCheckAccuracy(double accuracy)
Sets the accuracy to judge a mapped position coincides with a position in the other list when to check if the calculated map function is proper. It will be the mesh size to divide the check list map.
Parameters:
accuracy - the accuracy.

getScore

public double getScore()
Gets the matching score. It must be invoked after the run method was invoked.
Returns:
the matching score.

solve

public MapFunction solve()
                  throws MatchingFailedException
Solves matching between the specified lists of (x,y) positions and returns a MapFunction which converts (x,y) position in the first list to (x,y) position in the second list.
Returns:
the map function to convert (x,y) position.
Throws:
MatchingFailedException - if the best score after all searches is less than the specified score to fail.