Mercurial > hg > camir-aes2014
comparison toolboxes/graph_visualisation/include/graphviz/geom.h @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 /* $Id: geom.h,v 1.14 2009/06/03 01:10:52 ellson Exp $ $Revision: 1.14 $ */ | |
2 /* vim:set shiftwidth=4 ts=8: */ | |
3 | |
4 /********************************************************** | |
5 * This software is part of the graphviz package * | |
6 * http://www.graphviz.org/ * | |
7 * * | |
8 * Copyright (c) 1994-2004 AT&T Corp. * | |
9 * and is licensed under the * | |
10 * Common Public License, Version 1.0 * | |
11 * by AT&T Corp. * | |
12 * * | |
13 * Information and Software Systems Research * | |
14 * AT&T Research, Florham Park NJ * | |
15 **********************************************************/ | |
16 | |
17 /* geometric types and macros (e.g. points and boxes) with application to, but | |
18 * no specific dependance on graphs */ | |
19 | |
20 #ifndef GV_GEOM_H | |
21 #define GV_GEOM_H | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include "arith.h" | |
25 #endif | |
26 | |
27 #ifdef __cplusplus | |
28 extern "C" { | |
29 #endif | |
30 | |
31 typedef struct { int x, y; } point; | |
32 | |
33 typedef struct pointf_s { double x, y; } pointf; | |
34 | |
35 /* tell pathplan/pathgeom.h */ | |
36 #define HAVE_POINTF_S | |
37 | |
38 typedef struct { point LL, UR; } box; | |
39 | |
40 typedef struct { pointf LL, UR; } boxf; | |
41 | |
42 #ifdef HAVE_CONFIG_H | |
43 | |
44 /* true if point p is inside box b */ | |
45 #define INSIDE(p,b) (BETWEEN((b).LL.x,(p).x,(b).UR.x) && BETWEEN((b).LL.y,(p).y,(b).UR.y)) | |
46 | |
47 /* true if boxes b0 and b1 overlap */ | |
48 #define OVERLAP(b0,b1) (((b0).UR.x >= (b1).LL.x) && ((b1).UR.x >= (b0).LL.x) && ((b0).UR.y >= (b1).LL.y) && ((b1).UR.y >= (b0).LL.y)) | |
49 | |
50 /* true if box b0 completely contains b1*/ | |
51 #define CONTAINS(b0,b1) (((b0).UR.x >= (b1).UR.x) && ((b0).UR.y >= (b1).UR.y) && ((b0).LL.x <= (b1).LL.x) && ((b0).LL.y <= (b1).LL.y)) | |
52 | |
53 /* expand box b as needed to enclose point p */ | |
54 #define EXPANDBP(b, p) ((b).LL.x = MIN((b).LL.x, (p).x), (b).LL.y = MIN((b).LL.y, (p).y), (b).UR.x = MAX((b).UR.x, (p).x), (b).UR.y = MAX((b).UR.y, (p).y)) | |
55 | |
56 /* expand box b0 as needed to enclose box b1 */ | |
57 #define EXPANDBB(b0, b1) ((b0).LL.x = MIN((b0).LL.x, (b1).LL.x), (b0).LL.y = MIN((b0).LL.y, (b1).LL.y), (b0).UR.x = MAX((b0).UR.x, (b1).UR.x), (b0).UR.y = MAX((b0).UR.y, (b1).UR.y)) | |
58 | |
59 /* clip box b0 to fit box b1 */ | |
60 #define CLIPBB(b0, b1) ((b0).LL.x = MAX((b0).LL.x, (b1).LL.x), (b0).LL.y = MAX((b0).LL.y, (b1).LL.y), (b0).UR.x = MIN((b0).UR.x, (b1).UR.x), (b0).UR.y = MIN((b0).UR.y, (b1).UR.y)) | |
61 | |
62 #define LEN2(a,b) (SQR(a) + SQR(b)) | |
63 #define LEN(a,b) (sqrt(LEN2((a),(b)))) | |
64 | |
65 #define DIST2(p,q) (LEN2(((p).x - (q).x),((p).y - (q).y))) | |
66 #define DIST(p,q) (sqrt(DIST2((p),(q)))) | |
67 | |
68 #define POINTS_PER_INCH 72 | |
69 #define POINTS_PER_PC ((double)POINTS_PER_INCH / 6) | |
70 #define POINTS_PER_CM ((double)POINTS_PER_INCH * 0.393700787) | |
71 #define POINTS_PER_MM ((double)POINTS_PER_INCH * 0.0393700787) | |
72 | |
73 #define POINTS(a_inches) (ROUND((a_inches)*POINTS_PER_INCH)) | |
74 #define PS2INCH(a_points) ((a_points)/(double)POINTS_PER_INCH) | |
75 | |
76 #define P2PF(p,pf) ((pf).x = (p).x,(pf).y = (p).y) | |
77 #define PF2P(pf,p) ((p).x = ROUND((pf).x),(p).y = ROUND((pf).y)) | |
78 | |
79 #define B2BF(b,bf) (P2PF((b).LL,(bf).LL),P2PF((b).UR,(bf).UR)) | |
80 #define BF2B(bf,b) (PF2P((bf).LL,(b).LL),PF2P((bf).UR,(b).UR)) | |
81 | |
82 #define APPROXEQ(a,b,tol) (ABS((a) - (b)) < (tol)) | |
83 #define APPROXEQPT(p,q,tol) (DIST2((p),(q)) < SQR(tol)) | |
84 | |
85 /* some common tolerance values */ | |
86 #define MILLIPOINT .001 | |
87 #define MICROPOINT .000001 | |
88 | |
89 #endif | |
90 | |
91 #ifdef __cplusplus | |
92 } | |
93 #endif | |
94 | |
95 #endif |