Graphviz 12.0.1~dev.20240716.0800
Loading...
Searching...
No Matches
geomprocs.h
Go to the documentation of this file.
1
9/*************************************************************************
10 * Copyright (c) 2011 AT&T Intellectual Property
11 * All rights reserved. This program and the accompanying materials
12 * are made available under the terms of the Eclipse Public License v1.0
13 * which accompanies this distribution, and is available at
14 * https://www.eclipse.org/legal/epl-v10.html
15 *
16 * Contributors: Details at https://graphviz.org
17 *************************************************************************/
18
19#pragma once
20
21#include <stdbool.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27
28#include "geom.h"
29
30#ifdef GVDLL
31#ifdef GVC_EXPORTS
32#define GEOMPROCS_API __declspec(dllexport)
33#else
34#define GEOMPROCS_API __declspec(dllimport)
35#endif
36#endif
37
38#ifndef GEOMPROCS_API
39#define GEOMPROCS_API /* nothing */
40#endif
41
43
44GEOMPROCS_API double ptToLine2 (pointf l1, pointf l2, pointf p);
45
49
51
53
54static inline point add_point(point p, point q)
55{
56 point r;
57
58 r.x = p.x + q.x;
59 r.y = p.y + q.y;
60 return r;
61}
62
63static inline pointf add_pointf(pointf p, pointf q)
64{
65 pointf r;
66
67 r.x = p.x + q.x;
68 r.y = p.y + q.y;
69 return r;
70}
71
72static inline pointf sub_pointf(pointf p, pointf q)
73{
74 pointf r;
75
76 r.x = p.x - q.x;
77 r.y = p.y - q.y;
78 return r;
79}
80
81static inline pointf mid_pointf(pointf p, pointf q)
82{
83 pointf r;
84
85 r.x = (p.x + q.x) / 2.;
86 r.y = (p.y + q.y) / 2.;
87 return r;
88}
89
90static inline pointf interpolate_pointf(double t, pointf p, pointf q)
91{
92 pointf r;
93
94 r.x = p.x + t * (q.x - p.x);
95 r.y = p.y + t * (q.y - p.y);
96 return r;
97}
98
99static inline point exch_xy(point p)
100{
101 point r;
102
103 r.x = p.y;
104 r.y = p.x;
105 return r;
106}
107
108static inline pointf exch_xyf(pointf p)
109{
110 pointf r;
111
112 r.x = p.y;
113 r.y = p.x;
114 return r;
115}
116
117static inline bool boxf_overlap(boxf b0, boxf b1) {
118 return OVERLAP(b0, b1);
119}
120
121static inline pointf perp (pointf p)
122{
123 pointf r;
124
125 r.x = -p.y;
126 r.y = p.x;
127 return r;
128}
129
130static inline pointf scale (double c, pointf p)
131{
132 pointf r;
133
134 r.x = c * p.x;
135 r.y = c * p.y;
136 return r;
137}
138
139#undef GEOMPROCS_API
140#ifdef __cplusplus
141}
142#endif
geometric types and macros (e.g. points and boxes)
#define OVERLAP(b0, b1)
Definition geom.h:48
static pointf mid_pointf(pointf p, pointf q)
Definition geomprocs.h:81
static point add_point(point p, point q)
Definition geomprocs.h:54
static pointf add_pointf(pointf p, pointf q)
Definition geomprocs.h:63
static pointf sub_pointf(pointf p, pointf q)
Definition geomprocs.h:72
static point exch_xy(point p)
Definition geomprocs.h:99
GEOMPROCS_API pointf cwrotatepf(pointf p, int cwrot)
Definition geom.c:147
static pointf scale(double c, pointf p)
Definition geomprocs.h:130
GEOMPROCS_API int lineToBox(pointf p1, pointf p2, boxf b)
Definition geom.c:47
GEOMPROCS_API pointf ccwrotatepf(pointf p, int ccwrot)
Definition geom.c:172
GEOMPROCS_API boxf flip_rec_boxf(boxf b, pointf p)
Definition geom.c:197
static pointf exch_xyf(pointf p)
Definition geomprocs.h:108
static bool boxf_overlap(boxf b0, boxf b1)
Definition geomprocs.h:117
static pointf interpolate_pointf(double t, pointf p, pointf q)
Definition geomprocs.h:90
static pointf perp(pointf p)
Definition geomprocs.h:121
GEOMPROCS_API double ptToLine2(pointf l1, pointf l2, pointf p)
Definition geom.c:218
#define GEOMPROCS_API
Definition geomprocs.h:39
GEOMPROCS_API void rect2poly(pointf *p)
Definition geom.c:139
GEOMPROCS_API int line_intersect(pointf a, pointf b, pointf c, pointf d, pointf *p)
Definition geom.c:235
Definition geom.h:41
Definition geom.h:27
int y
Definition geom.h:27
int x
Definition geom.h:27
double x
Definition geom.h:29
double y
Definition geom.h:29