forked from trainman419/fiducials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Map_Test.c
103 lines (82 loc) · 3.35 KB
/
Map_Test.c
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
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright (c) 2013-2014 by Wayne C. Gramlich. All rights reserved.
#include <assert.h>
#include "Arc.h"
#include "CV.h"
#include "File.h"
#include "Double.h"
#include "Integer.h"
#include "List.h"
#include "Logical.h"
#include "Map.h"
#include "String.h"
#include "Tag.h"
#include "Unsigned.h"
extern void Map__build(Map map);
int main(int arguments_size, char * arguments[]) {
Map map1 = Map__create(".", "Map_Test_Map",
(void *)0, Fiducials__arc_announce, Fiducials__tag_announce,
(String_Const)0, "main:Map__new");
Unsigned visit = map1->visit;
Double pi = 3.14159265358979323846264;
Double degrees_to_radians = pi / 180.0;
// Some angles (in radians) to use:
Double angle0 = 0.0 * degrees_to_radians;
Double angle10 = 10.0 * degrees_to_radians;
Double angle20 = 20.0 * degrees_to_radians;
Double angle30 = 30.0 * degrees_to_radians;
Double angle40 = 40.0 * degrees_to_radians;
Double angle45 = 45.0 * degrees_to_radians;
Double angle90 = 90.0 * degrees_to_radians;
Double angle135 = 135.0 * degrees_to_radians;
Double angle180 = 180.0 * degrees_to_radians;
Double square_root_200 = Double__square_root(10.0 * 10.0 + 10.0 * 10.0);
Double square_root_50 = Double__square_root(5.0 * 5.0 + 5.0 * 5.0);
// The test map looks as follows:
//
// 3---2
// |\ /|
// | 4 |
// |/ \|
// 0---1
Unsigned tag_size = 1.0;
Tag tag0 = Map__tag_lookup(map1, 0);
Tag__initialize(tag0, 0.0, 0.0, 0.0, tag_size, visit);
Tag tag1 = Map__tag_lookup(map1, 1);
Tag__initialize(tag1, 0.0, 0.0, 0.0, tag_size, visit);
Tag tag2 = Map__tag_lookup(map1, 2);
Tag__initialize(tag2, 0.0, 0.0, 0.0, tag_size, visit);
Tag tag3 = Map__tag_lookup(map1, 3);
Tag__initialize(tag3, 0.0, 0.0, 0.0, tag_size, visit);
Tag tag4 = Map__tag_lookup(map1, 4);
Tag__initialize(tag4, 0.0, 0.0, 0.0, tag_size, visit);
// The tags are twisted by the tag id x 10 degerees. Thus, tag
// 0 has no twist, tag 1 is 10 degerees, ..., and tag 4 is 40 degrees.
// Sides:
Double d = 10.0;
Arc__create(tag0, 0.0 + 0.0, d, tag1, -angle180 + angle10, 0.0);
Arc__create(tag1, -angle90 + angle10, d, tag2, angle90 + angle20, 0.0);
Arc__create(tag0, -angle90, d, tag3, angle90 + angle30, 0.0);
Arc__create(tag2, -angle180 + angle20, d, tag3, 0.0 + angle30, 0.0);
// Arcs to center:
d = square_root_50;
Arc__create(tag0, -angle45, d, tag4, angle135 + angle40, 0.0);
Arc__create(tag1, -angle135 + angle10, d, tag4, angle135 + angle40, 0.0);
Arc__create(tag2, -angle45 + angle20, d, tag4, -angle45 + angle40, 0.0);
Arc__create(tag3, angle45 + angle30, d, tag4, -angle135 + angle40, 0.0);
// Large diagonals:
d = square_root_200;
//Arc__create(tag0, ??, square_root_200, tag2, ??, 0.0);
//Arc__create(tag1, ??, square_root_200, tag3, ??, 0.0);
Map__update(map1, (CV_Image)0, 0);
Map__save(map1);
Map map2 = Map__create(".", "Map_Test_Map",
(void *)0, Fiducials__arc_announce, Fiducials__tag_announce,
(String_Const)0, "main:Map__new");
assert (Map__compare(map1, map2) == 0);
List /*<Location>*/ locations =
List__new("Map_test:main:List__new:locations");
Map__svg_write(map1, "Map_Test", locations);
return 0;
}
void Map__build(Map map) {
}