Graphviz
14.1.3~dev.20260126.0926
Loading...
Searching...
No Matches
inpoly.c
Go to the documentation of this file.
1
/*************************************************************************
2
* Copyright (c) 2011 AT&T Intellectual Property
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* https://www.eclipse.org/legal/epl-v10.html
7
*
8
* Contributors: Details at https://graphviz.org
9
*************************************************************************/
10
11
/*
12
* in_poly
13
*
14
* Test if a point is inside a polygon.
15
* The polygon must be convex with vertices in CW order.
16
*/
17
18
#include "config.h"
19
20
#include <
pathplan/pathutil.h
>
21
#include <
pathplan/vispath.h
>
22
#include <stdbool.h>
23
#include <stddef.h>
24
#include <stdlib.h>
25
26
bool
in_poly
(
const
Ppoly_t
poly
,
Ppoint_t
q) {
27
const
Ppoint_t
*P =
poly
.ps;
28
const
size_t
n =
poly
.pn;
29
for
(
size_t
i = 0; i < n; i++) {
30
const
size_t
i1 = (i + n - 1) % n;
// point index; i1 = i-1 mod n
31
if
(
wind
(P[i1], P[i], q) == 1)
32
return
false
;
33
}
34
return
true
;
35
}
in_poly
bool in_poly(const Ppoly_t poly, Ppoint_t q)
Definition
inpoly.c:26
pathutil.h
wind
PATHUTIL_API int wind(Ppoint_t a, Ppoint_t b, Ppoint_t c)
Definition
visibility.c:55
Ppoly_t
Definition
pathgeom.h:45
Pxy_t
Definition
pathgeom.h:37
poly_s
Definition
tclpathplan.c:51
vispath.h
lib
pathplan
inpoly.c
Generated by
1.9.8