|
Graphviz
2.29.20120524.0446
|
00001 /* $Id$ $Revision$ */ 00002 /* vim:set shiftwidth=4 ts=8: */ 00003 00004 /************************************************************************* 00005 * Copyright (c) 2011 AT&T Intellectual Property 00006 * All rights reserved. This program and the accompanying materials 00007 * are made available under the terms of the Eclipse Public License v1.0 00008 * which accompanies this distribution, and is available at 00009 * http://www.eclipse.org/legal/epl-v10.html 00010 * 00011 * Contributors: See CVS logs. Details at http://www.graphviz.org/ 00012 *************************************************************************/ 00013 00014 /* 00015 * in_poly 00016 * 00017 * Test if a point is inside a polygon. 00018 * The polygon must be convex with vertices in CW order. 00019 */ 00020 00021 #include <stdlib.h> 00022 #include "vispath.h" 00023 #include "pathutil.h" 00024 00025 #ifdef DMALLOC 00026 #include "dmalloc.h" 00027 #endif 00028 00029 int in_poly(Ppoly_t poly, Ppoint_t q) 00030 { 00031 int i, i1; /* point index; i1 = i-1 mod n */ 00032 int n; 00033 Ppoint_t *P; 00034 00035 P = poly.ps; 00036 n = poly.pn; 00037 for (i = 0; i < n; i++) { 00038 i1 = (i + n - 1) % n; 00039 if (wind(P[i1],P[i],q) == 1) return FALSE; 00040 } 00041 return TRUE; 00042 }
1.7.5