Graphviz
13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
geom.h
Go to the documentation of this file.
1
10
/*************************************************************************
11
* Copyright (c) 2011 AT&T Intellectual Property
12
* All rights reserved. This program and the accompanying materials
13
* are made available under the terms of the Eclipse Public License v1.0
14
* which accompanies this distribution, and is available at
15
* https://www.eclipse.org/legal/epl-v10.html
16
*
17
* Contributors: Details at https://graphviz.org
18
*************************************************************************/
19
#pragma once
20
21
#include "
arith.h
"
22
23
#ifdef __cplusplus
24
extern
"C"
{
25
#endif
26
27
typedef
struct
{
int
x
, y; }
point
;
28
29
typedef
struct
pointf_s
{
double
x
,
y
; }
pointf
;
30
31
typedef
struct
{
32
pointf
p
;
// arbitrary point on the line
33
double
m
;
// slope of the line
34
}
linef
;
35
36
/* tell pathplan/pathgeom.h */
37
#define HAVE_POINTF_S
38
39
typedef
struct
{
point
LL
, UR; }
box
;
40
41
typedef
struct
{
pointf
LL
, UR; }
boxf
;
42
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
#define LEN2(a,b) (SQR(a) + SQR(b))
60
61
#define DIST2(p,q) (LEN2(((p).x - (q).x),((p).y - (q).y)))
62
#define DIST(p,q) (sqrt(DIST2((p),(q))))
63
64
#define POINTS_PER_INCH 72
65
#define POINTS_PER_CM ((double)POINTS_PER_INCH * 0.393700787)
66
#define POINTS_PER_MM ((double)POINTS_PER_INCH * 0.0393700787)
67
68
#define POINTS(a_inches) (ROUND((a_inches)*POINTS_PER_INCH))
69
#define INCH2PS(a_inches) ((a_inches)*(double)POINTS_PER_INCH)
70
#define PS2INCH(a_points) ((a_points)/(double)POINTS_PER_INCH)
71
72
#define P2PF(p,pf) ((pf).x = (p).x,(pf).y = (p).y)
73
#define PF2P(pf,p) ((p).x = ROUND((pf).x),(p).y = ROUND((pf).y))
74
75
#define B2BF(b,bf) (P2PF((b).LL,(bf).LL),P2PF((b).UR,(bf).UR))
76
77
#define APPROXEQPT(p,q,tol) (DIST2((p),(q)) < SQR(tol))
78
79
/* common tolerance value */
80
#define MILLIPOINT .001
81
82
#ifdef __cplusplus
83
}
84
#endif
arith.h
pointf
struct pointf_s pointf
box
Definition
geom.h:39
box::LL
point LL
Definition
geom.h:39
boxf
Definition
geom.h:41
boxf::LL
pointf LL
Definition
geom.h:41
linef
Definition
geom.h:31
linef::p
pointf p
Definition
geom.h:32
linef::m
double m
Definition
geom.h:33
point
Definition
geom.h:27
point::x
int x
Definition
geom.h:27
pointf_s
Definition
geom.h:29
pointf_s::x
double x
Definition
geom.h:29
pointf_s::y
double y
Definition
geom.h:29
lib
common
geom.h
Generated by
1.9.8