11 #define EPSILON 0.000001
20 point_t p1, p2, p3, p4, p5, p6, p7, p;
21 point_t p8, p9, p10, p11;
22 line_t l1, l2, l3, l4;
30 polygon_set_boundingbox(25, 25, 275, 185);
37 if (v.x != 0 || v.y != 1)
38 printf("error rot rigo ok1\r\n");
44 if (v.x != 1 || v.y != 0)
45 printf("error rot trigo ok2\r\n");
48 if (v.x != 0 || v.y != -1)
49 printf("error rot rigo ok1\r\n");
55 if (v.x != 1 || v.y != 0)
56 printf("error rot retro ok2\r\n");
62 ps = vect_pscal(&v, &w);
66 if (fabs(n1-1.)>EPSILON || fabs(n2-2.828427)>EPSILON)
67 printf("error in norm\r\n");
69 a = acos((float)ps/(n1*n2))*180./M_PI;
71 if (fabs(a-45.)>EPSILON)
72 printf("error in norm/pscal\r\n");
74 a = vect_get_angle(&v, &w)*180./M_PI;
75 if (fabs(a-45.)>EPSILON)
76 printf("error in get angle\r\n");
78 /* basic lines tests */
85 pts2line(&p1, &p2, &l1);
86 printf("%2.2f %2.2f %2.2f\r\n", l1.a, l1.b, l1.c);
92 pts2line(&p1, &p3, &l2);
93 printf("%2.2f %2.2f %2.2f\r\n", l2.a, l2.b, l2.c);
102 pts2line(&p4, &p5, &l3);
103 printf("%2.2f %2.2f %2.2f\r\n", l3.a, l3.b, l3.c);
111 pts2line(&p6, &p7, &l4);
112 printf("%2.2f %2.2f %2.2f\r\n", l4.a, l4.b, l4.c);
115 intersect_line(&l1, &l2, &p);
116 printf("* %" PRIi32 " %" PRIi32 "\r\n", p.x, p.y);
118 intersect_line(&l1, &l4, &p);
119 printf("* %" PRIi32 " %" PRIi32 "\r\n", p.x, p.y);
121 intersect_line(&l2, &l4, &p);
122 printf("* %" PRIi32 " %" PRIi32 "\r\n", p.x, p.y);
124 intersect_line(&l3, &l4, &p);
125 printf("* %" PRIi32 " %" PRIi32 "\r\n", p.x, p.y);
127 ret = intersect_segment(&p1, &p2, &p4, &p5, &p);
128 printf("%d (%" PRIi32 " %" PRIi32 ")\r\n", ret, p.x, p.y);
130 printf("error in segment cros\r\n");
132 ret = intersect_segment(&p4, &p5, &p6, &p7, &p);
133 printf("%d (%" PRIi32 " %" PRIi32 ")\r\n", ret, p.x, p.y);
135 printf("error in segment cros\r\n");
137 ret = intersect_segment(&p1, &p2, &p1, &p3, &p);
138 printf("%d (%" PRIi32 " %" PRIi32 ")\r\n", ret, p.x, p.y);
140 printf("error in segment cros\r\n");
150 ret = intersect_segment(&p8, &p9, &p10, &p11, &p);
151 printf("%d (%" PRIi32 " %" PRIi32 ")\r\n", ret, p.x, p.y);
153 printf("error in segment cros\r\n");
167 pts2line(&p6, &p7, &l3);
168 proj_pt_line(&p8, &l3, &p);
169 printf("proj: %" PRIi32 " %" PRIi32 "\r\n", p.x, p.y);
170 if (p.x != 15 || p.y != 15)
171 printf("error in proj 1\r\n");
183 pts2line(&p6, &p7, &l3);
184 proj_pt_line(&p8, &l3, &p);
185 printf("proj: %" PRIi32 " %" PRIi32 "\r\n", p.x, p.y);
186 if (p.x != 0 || p.y != 10)
187 printf("error in proj 2\r\n");
199 pts2line(&p6, &p7, &l3);
200 proj_pt_line(&p8, &l3, &p);
201 printf("proj: %" PRIi32 " %" PRIi32 "\r\n", p.x, p.y);
202 if (p.x != 10 || p.y != 0)
203 printf("error in proj 3\r\n");
212 pts2line(&p1, &p2, &l1);
213 printf("%2.2f %2.2f %2.2f\r\n", l1.a, l1.b, l1.c);
221 pts2line(&p1, &p2, &l1);
222 printf("%2.2f %2.2f %2.2f\r\n", l1.a, l1.b, l1.c);
225 /* basic poly tests */
227 poly1.pts = poly_pts1;
230 poly2.pts = poly_pts2;
261 ret = is_in_poly(&p6, &poly1);
262 printf("%d\r\n", ret);
264 printf("error in is in poly\r\n");
268 ret = is_in_poly(&p4, &poly1);
269 printf("%d\r\n", ret);
271 printf("error in is in poly\r\n");
274 ret = is_in_poly(&p1, &poly1);
275 printf("%d\r\n", ret);
277 printf("error in is in poly\r\n");