aboutsummaryrefslogtreecommitdiff
path: root/generic/Transfo.h
blob: c10621b3cf8ed4f16d92588f271168590d84c9ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 * Transfo.h -- Header for common geometric routines.
 *
 * Authors		: Patrick Lecoanet.
 * Creation date	:
 *
 * $Id$
 */

/*
 *  Copyright (c) 1993 - 1999 CENA, Patrick Lecoanet --
 *
 * This code is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this code; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */


#ifndef _Transfo_h
#define _Transfo_h


#include "Types.h"

#include <math.h>
#include <limits.h>


/*
 * First subscript is matrix row, second is matrix column.
 * So a[0][1] is upper right corner of matrix a and a[2][0]
 * is lower left corner.
 */
typedef struct  _ZnTransfo {
  float	_[3][2];
} ZnTransfo;


ZnTransfo *
ZnTransfoNew(void);
ZnTransfo *
ZnTransfoDuplicate(ZnTransfo *t);
void
ZnTransfoFree(ZnTransfo	*t);
void
ZnPrintTransfo(ZnTransfo	*t);
void
ZnTransfoSetIdentity(ZnTransfo	*t);
ZnBool
ZnTransfoIsIdentity(ZnTransfo	*t);
ZnTransfo *
ZnTransfoCompose(ZnTransfo	*res,
		 ZnTransfo	*t1,
		 ZnTransfo	*t2);
ZnTransfo *
ZnTransfoInvert(ZnTransfo	*t,
		ZnTransfo	*inv);
void
ZnTransfoDecompose(ZnTransfo	*t,
		   ZnPoint	*scale,
		   ZnPoint	*trans,
		   ZnReal	*rotation,
		   ZnReal	*skewxy);
ZnBool
ZnTransfoEqual(ZnTransfo	*t1,
	       ZnTransfo	*t2,
	       ZnBool		include_translation);
ZnBool
ZnTransfoHasSkew(ZnTransfo	*t);
ZnBool
ZnTransfoIsTranslation(ZnTransfo	*t);
ZnPoint *
ZnTransformPoint(ZnTransfo	*t,
		 ZnPoint	*p,
		 ZnPoint	*xp);
void
ZnTransformPoints(ZnTransfo	*t,
		  ZnPoint	*p,
		  ZnPoint	*xp,
		  unsigned int	num);
ZnTransfo *
ZnTranslate(ZnTransfo	*t,
	    ZnReal	delta_x,
	    ZnReal	delta_y,
	    ZnBool	abs);
ZnTransfo *
ZnScale(ZnTransfo	*t,
	ZnReal		scale_x,
	ZnReal		scale_y);
ZnTransfo *
ZnRotateRad(ZnTransfo	*t,
	    ZnReal	angle);
ZnTransfo *
ZnRotateDeg(ZnTransfo	*t,
	    ZnReal	angle);
ZnTransfo *
ZnSkewRad(ZnTransfo	*t,
	  ZnReal	skew_x,
	  ZnReal	skew_y);
ZnTransfo *
ZnSkewDeg(ZnTransfo	*t,
	  ZnReal	skew_x,
	  ZnReal	skew_y);

#endif	/* _Transfo_h */