2 * Copyright Droids Corporation (2009)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: f16.h,v 1.6.4.3 2008-05-10 15:06:26 zer0 Exp $
25 typedef struct _poly {
30 /* XXX add const, fix arg order */
38 uint8_t is_in_poly(const point_t *p, poly_t *pol);
41 * public wrapper for is_in_poly()
46 uint8_t is_point_in_poly(poly_t *pol, int16_t x, int16_t y);
48 /* Is segment crossing polygon? (including edges)
52 * 3 touch out (a segment boundary is on a polygon edge,
53 * and the second segment boundary is out of the polygon)
54 * Fill the intersect_pt if not NULL.
57 is_crossing_poly(point_t p1, point_t p2, point_t *intersect_pt,
61 * set coords of bounding box.
63 void polygon_set_boundingbox(int32_t x1, int32_t y1, int32_t x2, int32_t y2);
66 * return 1 if a point is in the bounding box.
68 uint8_t is_in_boundingbox(const point_t *p);
70 /* Giving the list of poygons, compute the graph of "visibility rays".
71 * This rays array is composed of indexes representing 2 polygon
72 * vertices that can "see" each others:
74 * i : the first polygon number in the input polygon list
75 * i+1: the vertex index of this polygon (vertex 1)
76 * i+2: the second polygon number in the input polygon list
77 * i+3: the vertex index of this polygon (vertex 2)
79 * Here, vertex 1 can "see" vertex 2 in our visibility graph
81 * As the first polygon is not a real polygon but the start/stop
82 * point, the polygon is NOT an ocluding polygon (but its vertices
83 * are used to compute visibility to start/stop points)
87 calc_rays(poly_t *polys, uint8_t npolys, uint8_t *rays);
89 /* Compute the weight of every rays: the length of the rays is used
92 * Note the +1 is a little hack to introduce a preference between to
93 * possiblity path: If we have 3 checpoint aligned in a path (say A,
94 * B, C) the algorithm will prefer (A, C) instead of (A, B, C) */
96 calc_rays_weight(poly_t *polys, uint8_t npolys, uint8_t *rays,
97 uint8_t ray_n, uint16_t *weight);