xref: /potrace-1.14/src/trans.h (revision b3fce824)
1 /* Copyright (C) 2001-2017 Peter Selinger.
2    This file is part of Potrace. It is free software and it is covered
3    by the GNU General Public License. See the file COPYING for details. */
4 
5 
6 #ifndef TRANS_H
7 #define TRANS_H
8 
9 #include "auxiliary.h"
10 
11 /* structure to hold a coordinate transformation */
12 struct trans_s {
13   double bb[2];    /* dimensions of bounding box */
14   double orig[2];  /* origin relative to bounding box */
15   double x[2];     /* basis vector for the "x" direction */
16   double y[2];     /* basis vector for the "y" direction */
17   double scalex, scaley;  /* redundant info for some backends' benefit */
18 };
19 typedef struct trans_s trans_t;
20 
21 /* apply a coordinate transformation to a point */
trans(dpoint_t p,trans_t t)22 static inline dpoint_t trans(dpoint_t p, trans_t t) {
23   dpoint_t res;
24 
25   res.x = t.orig[0] + p.x * t.x[0] + p.y * t.y[0];
26   res.y = t.orig[1] + p.x * t.x[1] + p.y * t.y[1];
27   return res;
28 }
29 
30 void trans_rotate(trans_t *r, double alpha);
31 void trans_from_rect(trans_t *r, double w, double h);
32 void trans_rescale(trans_t *r, double sc);
33 void trans_scale_to_size(trans_t *r, double w, double h);
34 void trans_tighten(trans_t *r, potrace_path_t *plist);
35 
36 #endif /* TRANS_H */
37