| 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 |
#include "trans.h" |
| 34 |
|
| 35 |
void makeidentity(transform* t) |
| 36 |
{ |
| 37 |
t->a = 1.0; |
| 38 |
t->b = 0.0; |
| 39 |
t->c = 0.0; |
| 40 |
t->d = 1.0; |
| 41 |
t->x = 0.0; |
| 42 |
t->y = 0.0; |
| 43 |
} |
| 44 |
|
| 45 |
void makescale(transform* t, double xscale, double yscale) |
| 46 |
{ |
| 47 |
t->a = xscale; |
| 48 |
t->b = 0.0; |
| 49 |
t->c = 0.0; |
| 50 |
t->d = yscale; |
| 51 |
t->x = 0.0; |
| 52 |
t->y = 0.0; |
| 53 |
} |
| 54 |
|
| 55 |
void maketranslation(transform* t, double dx, double dy) |
| 56 |
{ |
| 57 |
t->a = 1.0; |
| 58 |
t->b = 0.0; |
| 59 |
t->c = 0.0; |
| 60 |
t->d = 1.0; |
| 61 |
t->x = dx; |
| 62 |
t->y = dy; |
| 63 |
} |
| 64 |
#include <stdio.h> |
| 65 |
void makerotation(transform* t, double a) |
| 66 |
{ |
| 67 |
t->a = cos(a); |
| 68 |
t->b = sin(a); |
| 69 |
t->c = -sin(a); |
| 70 |
t->d = cos(a); |
| 71 |
t->x = 0.0; |
| 72 |
t->y = 0.0; |
| 73 |
} |
| 74 |
|
| 75 |
void transformpoint(realpoint* p, const transform* t) |
| 76 |
{ |
| 77 |
realpoint r; |
| 78 |
r.x = t->a * p->x + t->c * p->y + t->x; |
| 79 |
r.y = t->b * p->x + t->d * p->y + t->y; |
| 80 |
*p = r; |
| 81 |
} |
| 82 |
|
| 83 |
void transformconcat(transform* t1, const transform* t2) |
| 84 |
{ |
| 85 |
transform r; |
| 86 |
r.a = t1->a * t2->a + t1->b * t2->c + 0.0 * t2->x; |
| 87 |
r.b = t1->a * t2->b + t1->b * t2->d + 0.0 * t2->y; |
| 88 |
r.c = t1->c * t2->a + t1->d * t2->c + 0.0 * t2->x; |
| 89 |
r.d = t1->c * t2->b + t1->d * t2->d + 0.0 * t2->y; |
| 90 |
r.x = t1->x * t2->a + t1->y * t2->c + 1.0 * t2->x; |
| 91 |
r.y = t1->x * t2->b + t1->y * t2->d + 1.0 * t2->y; |
| 92 |
*t1 = r; |
| 93 |
} |