Graphviz 13.0.0~dev.20250121.0651
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
24extern "C" {
25#endif
26
27typedef struct { int x, y; } point;
28
29typedef struct pointf_s { double x, y; } pointf;
30
31typedef 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
39typedef struct { point LL, UR; } box;
40
41typedef 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#define LEN2(a,b) (SQR(a) + SQR(b))
54
55#define DIST2(p,q) (LEN2(((p).x - (q).x),((p).y - (q).y)))
56#define DIST(p,q) (sqrt(DIST2((p),(q))))
57
58#define POINTS_PER_INCH 72
59#define POINTS_PER_CM ((double)POINTS_PER_INCH * 0.393700787)
60#define POINTS_PER_MM ((double)POINTS_PER_INCH * 0.0393700787)
61
62#define POINTS(a_inches) (ROUND((a_inches)*POINTS_PER_INCH))
63#define INCH2PS(a_inches) ((a_inches)*(double)POINTS_PER_INCH)
64#define PS2INCH(a_points) ((a_points)/(double)POINTS_PER_INCH)
65
66#define P2PF(p,pf) ((pf).x = (p).x,(pf).y = (p).y)
67#define PF2P(pf,p) ((p).x = ROUND((pf).x),(p).y = ROUND((pf).y))
68
69#define B2BF(b,bf) (P2PF((b).LL,(bf).LL),P2PF((b).UR,(bf).UR))
70
71#define APPROXEQPT(p,q,tol) (DIST2((p),(q)) < SQR(tol))
72
73/* common tolerance value */
74#define MILLIPOINT .001
75
76#ifdef __cplusplus
77}
78#endif
struct pointf_s pointf
Definition geom.h:39
point LL
Definition geom.h:39
Definition geom.h:41
pointf LL
Definition geom.h:41
Definition geom.h:31
pointf p
Definition geom.h:32
double m
Definition geom.h:33
Definition geom.h:27
int x
Definition geom.h:27
double x
Definition geom.h:29
double y
Definition geom.h:29