1 /****************************************************************************\ 2 Part of the XeTeX typesetting system 3 Copyright (c) 1994-2008 by SIL International 4 Copyright (c) 2009 by Jonathan Kew 5 6 SIL Author(s): Jonathan Kew 7 8 Permission is hereby granted, free of charge, to any person obtaining 9 a copy of this software and associated documentation files (the 10 "Software"), to deal in the Software without restriction, including 11 without limitation the rights to use, copy, modify, merge, publish, 12 distribute, sublicense, and/or sell copies of the Software, and to 13 permit persons to whom the Software is furnished to do so, subject to 14 the following conditions: 15 16 The above copyright notice and this permission notice shall be 17 included in all copies or substantial portions of the Software. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE 23 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 24 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 27 Except as contained in this notice, the name of the copyright holders 28 shall not be used in advertising or otherwise to promote the sale, 29 use or other dealings in this Software without prior written 30 authorization from the copyright holders. 31 \****************************************************************************/ 32 33 #ifndef _TRANS_H_ 34 #define _TRANS_H_ 35 36 #include <math.h> 37 /* apparently M_PI isn't defined by <math.h> under VC++ */ 38 #ifndef M_PI 39 #define M_PI 3.14159265358979323846 40 #endif 41 42 typedef struct { 43 double a; 44 double b; 45 double c; 46 double d; 47 double x; 48 double y; 49 } transform; 50 51 typedef struct { 52 float x; 53 float y; 54 } realpoint; 55 56 typedef struct { 57 float x; 58 float y; 59 float wd; 60 float ht; 61 } realrect; 62 63 #define xCoord(p) (p).x 64 #define yCoord(p) (p).y 65 66 #define wdField(r) (r).wd 67 #define htField(r) (r).ht 68 69 #define aField(t) (t).a 70 #define bField(t) (t).b 71 #define cField(t) (t).c 72 #define dField(t) (t).d 73 #define xField(t) (t).x 74 #define yField(t) (t).y 75 76 #define setPoint(P,X,Y) do { (P).x = X; (P).y = Y; } while (0) 77 78 #ifdef __cplusplus 79 extern "C" { 80 #endif 81 void makeidentity(transform* t); 82 void makescale(transform* t, double xscale, double yscale); 83 void maketranslation(transform* t, double dx, double dy); 84 void makerotation(transform* t, double a); 85 void transformpoint(realpoint* p, const transform* t); 86 void transformconcat(transform* t1, const transform* t2); 87 #ifdef __cplusplus 88 }; 89 #endif 90 91 #endif /* _TRANS_H_ */ 92