-
Notifications
You must be signed in to change notification settings - Fork 0
/
apollonius_test.cpp
106 lines (95 loc) · 2.85 KB
/
apollonius_test.cpp
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
104
105
106
#include "apollonius.h"
#include <iostream>
#define APO_INIT \
apo_t* apo = apo_init(); \
if (!apo) \
return;
#define APO_SOLVE \
apo_solution* solution = nullptr; \
apo_solve(apo, &solution); \
if (!solution) \
{ \
apo_destroy(apo); \
return; \
} \
unsigned int size = apo_solution_get_count(solution); \
std::cout << "solution size is : " << size << std::endl; \
for (unsigned int i = 0; i < size; ++i) \
{ \
double cx, cy, radius; \
apo_solution_get_circle(solution, i, &cx, &cy, &radius); \
std::cout << "circle " << i << " is (" << cx << ", " << cy \
<< "), radius is " << radius << std::endl; \
} \
apo_solution_destroy(solution); \
apo_destroy(apo);
void
test_ppp()
{
{
APO_INIT
apo_add_point(apo, 0, 0);
apo_add_point(apo, 5, 5);
apo_add_point(apo, 10, 0);
APO_SOLVE
}
{
APO_INIT
apo_add_point(apo, 0, 0);
apo_add_point(apo, 0, 0);
apo_add_point(apo, 0, 0);
APO_SOLVE
}
}
void
test_ppl()
{
APO_INIT
apo_add_point(apo, 20, 50);
apo_add_point(apo, 40, 50);
apo_add_line(apo, 10, 60, 50, 60);
APO_SOLVE
}
void
test_ppc()
{
{
APO_INIT
apo_add_point(apo, 30, 60);
apo_add_point(apo, 50, 50);
apo_add_circle(apo, 30, 40, 10);
APO_SOLVE
}
}
void
test_lll()
{
APO_INIT
apo_add_line(apo, 0, 10, 10, 20);
apo_add_line(apo, 20, 20, 30, 10);
apo_add_line(apo, 10, 0, 20, 0);
APO_SOLVE
//-20.35533906,25,25
//50.35533906,25,25
//15,-60.35533906,60.35533906
//15,10.35533906,10.35533906
}
void
test_llc()
{
APO_INIT
apo_add_circle(apo, 30, 10, 10);
apo_add_line(apo, 10, 20, 20, 30);
apo_add_line(apo, 40, 30, 50, 20);
APO_SOLVE
// 30,28.28427125,8.28427125
// 30,16.56854249,16.56854249
// 30,-28.28427125,48.28427125
// 30,-96.56854249,96.56854249
}
int
main()
{
test_ppp();
return 0;
}