/
MapRecog.java
90 lines (71 loc) · 1.56 KB
/
MapRecog.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import java.awt.geom.Ellipse2D;
import java.util.ArrayList;
class MapRecog
{
private Maze maze1;
private Maze maze2;
private double maze1dist[][];
private double maze2dist[][];
public MapRecog()
{
maze1 = null;
maze2 = null;
}
public void setMaze(Maze m, int x)
{
if(x == 1)
{
maze1 = m;
}
if(x == 2)
{
maze2 = m;
}
}
public boolean attemptMatch()
{
if(maze1 == null || maze2 == null)
return false;
ArrayList<NoisyPoint> map = new ArrayList<NoisyPoint>();
for(NoisyPoint np : maze1.getMaze())
map.add(np);
maze1dist = formDistanceGraph(maze1,map);
map = new ArrayList<NoisyPoint>();
for(NoisyPoint np : maze2.getMaze())
map.add(np);
maze2dist = formDistanceGraph(maze2,map);
checkPoints(maze1dist,maze2dist);
return false;
}
private double[][] formDistanceGraph(Maze m, ArrayList<NoisyPoint> points)
{
double temp[][] = new double[m.getMaze().size()][m.getMaze().size()];
for(int x = 0; x < temp.length; x++)
for(int y = 0; y < temp.length; y++)
temp[x][y] = getDistance(points.get(x),points.get(y));
return temp;
}
private void checkPoints(double p1[][], double p2[][])
{
double temp[] = p1[0];
for(int x = 0; x < temp.length; x++)
{
if(temp[x] != 0)
{
for(int r = 0; r < p2.length; r++)
for(int c = 0; c < p2.length; c++)
if(temp[x] == p2[r][c])
bounce();
}
}
}
/* TODO */
/* skeleton */
private void bounce()
{
}
private double getDistance(NoisyPoint one, NoisyPoint two)
{
return Math.sqrt(Math.pow((one.x-two.x),2)+Math.pow((one.y-two.y),2));
}
}