Added comment to prevent myself from doing something silly in the future.
[trakem2.git] / mpi / fruitfly / registration / SimPoint2DMatch.java
blobd2f235c14eed3c378284fb0b9e33faddf3474ae2
1 package mpi.fruitfly.registration;
3 import java.util.ArrayList;
4 import java.util.Collection;
6 public class SimPoint2DMatch
8 public SimPoint2D s1;
9 public SimPoint2D s2;
11 private float distance;
12 private float xDistance;
13 private float yDistance;
14 private float rDistance;
16 final public float getDistance(){ return distance; }
17 final public float getXDistance(){ return xDistance; }
18 final public float getYDistance(){ return yDistance; }
19 final public float getRDistance(){ return rDistance; }
21 public SimPoint2DMatch(
22 SimPoint2D s1,
23 SimPoint2D s2 )
25 this.s1 = s1;
26 this.s2 = s2;
28 distance = SimPoint2D.distance( s1, s2 );
31 final public void apply( Model model )
33 s1.apply( model );
34 distance = SimPoint2D.distance( s1, s2 );
37 final public static ArrayList< SimPoint2DMatch > fromMatches( Collection< Match > matches )
39 ArrayList< SimPoint2DMatch > list = new ArrayList< SimPoint2DMatch >();
40 float weight = 1.0f / ( float )matches.size();
41 for ( Match match : matches )
43 list.add(
44 new SimPoint2DMatch(
45 new SimPoint2D(
46 match.p1[ 0 ],
47 match.p1[ 1 ],
48 0.0f,
49 weight ),
50 new SimPoint2D(
51 match.p2[ 0 ],
52 match.p2[ 1 ],
53 0.0f,
54 weight ) ) );
56 return list;
59 final public static ArrayList< Match > toMatches( Collection< SimPoint2DMatch > matches )
61 ArrayList< Match > list = new ArrayList< Match >();
62 for ( SimPoint2DMatch match : matches )
64 list.add(
65 new Match(
66 new float[]{ match.s1.getWtx(), match.s1.getWty() },
67 new float[]{ match.s2.getWtx(), match.s2.getWty() },
68 match.s1.getWeight(),
69 match.s2.getWeight() ) );
71 return list;
74 final public static ArrayList< SimPoint2DMatch > flip( Collection< SimPoint2DMatch > matches )
76 ArrayList< SimPoint2DMatch > list = new ArrayList< SimPoint2DMatch >();
77 for ( SimPoint2DMatch match : matches )
79 list.add(
80 new SimPoint2DMatch(
81 match.s2,
82 match.s1 ) );
84 return list;