File indexing completed on 2025-12-16 10:18:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
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;
0033 double m;
0034 } linef;
0035
0036
0037 #define HAVE_POINTF_S
0038
0039 typedef struct { point LL, UR; } box;
0040
0041 typedef struct { pointf LL, UR; } boxf;
0042
0043
0044
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
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
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
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
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
0080 #define MILLIPOINT .001
0081
0082 #ifdef __cplusplus
0083 }
0084 #endif