Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:18:20

0001 /**
0002  * @file
0003  * @brief geometric types and macros (e.g. points and boxes)
0004  * @ingroup public_apis
0005  * @ingroup common_utils
0006  *
0007  * with application to, but no specific dependence on graphs
0008  */
0009 
0010 /*************************************************************************
0011  * Copyright (c) 2011 AT&T Intellectual Property 
0012  * All rights reserved. This program and the accompanying materials
0013  * are made available under the terms of the Eclipse Public License v1.0
0014  * which accompanies this distribution, and is available at
0015  * https://www.eclipse.org/legal/epl-v10.html
0016  *
0017  * Contributors: Details at https://graphviz.org
0018  *************************************************************************/
0019 #pragma once
0020 
0021 #include "arith.h"
0022 
0023 #ifdef __cplusplus
0024 extern "C" {
0025 #endif
0026     
0027 typedef struct { int x, y; } point;
0028 
0029 typedef struct pointf_s { double x, y; } pointf;
0030 
0031 typedef struct {
0032   pointf p; // arbitrary point on the line
0033   double m; // slope of the line
0034 } linef;
0035 
0036 /* tell pathplan/pathgeom.h */
0037 #define HAVE_POINTF_S
0038 
0039 typedef struct { point LL, UR; } box;
0040 
0041 typedef struct { pointf LL, UR; } boxf;
0042 
0043 
0044 /* true if point p is inside box b */
0045 #define INSIDE(p,b) (BETWEEN((b).LL.x,(p).x,(b).UR.x) && BETWEEN((b).LL.y,(p).y,(b).UR.y))
0046 
0047 /* true if boxes b0 and b1 overlap */
0048 #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))
0049 
0050 /* true if box b0 completely contains b1*/
0051 #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))
0052 
0053 /* expand box b as needed to enclose point p */
0054 #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))
0055 
0056 /* expand box b0 as needed to enclose box b1 */
0057 #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))
0058 
0059 #define LEN2(a,b)       (SQR(a) + SQR(b))
0060 
0061 #define DIST2(p,q)      (LEN2(((p).x - (q).x),((p).y - (q).y)))
0062 #define DIST(p,q)       (sqrt(DIST2((p),(q))))
0063 
0064 #define POINTS_PER_INCH 72
0065 #define POINTS_PER_CM       ((double)POINTS_PER_INCH * 0.393700787)
0066 #define POINTS_PER_MM       ((double)POINTS_PER_INCH * 0.0393700787)
0067 
0068 #define POINTS(a_inches)    (ROUND((a_inches)*POINTS_PER_INCH))
0069 #define INCH2PS(a_inches)   ((a_inches)*(double)POINTS_PER_INCH)
0070 #define PS2INCH(a_points)   ((a_points)/(double)POINTS_PER_INCH)
0071 
0072 #define P2PF(p,pf)      ((pf).x = (p).x,(pf).y = (p).y)
0073 #define PF2P(pf,p)      ((p).x = ROUND((pf).x),(p).y = ROUND((pf).y))
0074 
0075 #define B2BF(b,bf)      (P2PF((b).LL,(bf).LL),P2PF((b).UR,(bf).UR))
0076 
0077 #define APPROXEQPT(p,q,tol) (DIST2((p),(q)) < SQR(tol))
0078 
0079 /* common tolerance value */
0080 #define MILLIPOINT .001
0081 
0082 #ifdef __cplusplus
0083 }
0084 #endif