summaryrefslogtreecommitdiff
path: root/include/freetype/fttrigon.h
blob: 311040f29948ea0f2f19b9da61bf60a6a568fdfc (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#ifndef __FT_TRIGONOMETRY_H__
#define __FT_TRIGONOMETRY_H__

FT_BEGIN_HEADER

 /***************************************************************************
  *
  * @section: computations
  *
  */

 /***************************************************************************
  *
  * @type: FT_Angle
  *
  * @description:
  *   this type is used to model angle values in FreeType. Note that
  *   the angle is a 16.16 fixed float value expressed in _degrees_
  */
  typedef FT_Fixed   FT_Angle;

 /***************************************************************************
  *
  * @macro: FT_ANGLE_PI
  *
  * @description:
  *   the angle pi expressed in @FT_Angle units
  */
#define  FT_ANGLE_PI   (180L << 16)

 /***************************************************************************
  *
  * @macro: FT_ANGLE_2PI
  *
  * @description:
  *   the angle 2pi expressed in @FT_Angle units
  */
#define  FT_ANGLE_2PI  (FT_ANGLE_PI*2)

 /***************************************************************************
  *
  * @macro: FT_ANGLE_PI2
  *
  * @description:
  *   the angle pi/2 expressed in @FT_Angle units
  */
#define  FT_ANGLE_PI2  (FT_ANGLE_PI/2)

 /***************************************************************************
  *
  * @macro: FT_ANGLE_PI4
  *
  * @description:
  *   the angle pi/4 expressed in @FT_Angle units
  */
#define  FT_ANGLE_PI4  (FT_ANGLE_PI/4)


 /***************************************************************************
  *
  * @function: FT_Sin
  *
  * @description:
  *   return the sinus of a given angle in fixed point format
  *
  * @input:
  *    angle :: input angle
  *
  * @return:
  *    sinus value
  *
  * @note:
  *   if you need both the sinus and cosinus for a given angle, you'd
  *   better use the function @FT_Vector_Unit
  */
  FT_EXPORT(FT_Fixed)    FT_Sin( FT_Angle  angle );

 /***************************************************************************
  *
  * @function: FT_Cos
  *
  * @description:
  *   return the cosinus of a given angle in fixed point format
  *
  * @input:
  *    angle :: input angle
  *
  * @return:
  *    cosinus value
  *
  * @note:
  *   if you need both the sinus and cosinus for a given angle, you'd
  *   better use the function @FT_Vector_Unit
  */
  FT_EXPORT(FT_Fixed)    FT_Cos( FT_Angle  angle );  

 /***************************************************************************
  *
  * @function: FT_Tan
  *
  * @description:
  *   return the tangent of a given angle in fixed point format
  *
  * @input:
  *   angle :: input angle
  *
  * @return:
  *   tangent value
  */
  FT_EXPORT(FT_Fixed)    FT_Tan( FT_Angle  angle );


 /***************************************************************************
  *
  * @function: FT_Atan2
  *
  * @description:
  *   return the arc-tangent corresponding to a given vector (x,y) in
  *   the 2d plane
  *
  * @input:
  *   x :: horizontal vector coordinate
  *   y :: vertical vector coordinate
  *
  * @return:
  *   arc-tangent value (i.e. angle)
  */
  FT_EXPORT(FT_Angle)    FT_Atan2( FT_Fixed  x, FT_Fixed  y );


 /***************************************************************************
  *
  * @function: FT_Vector_Unit
  *
  * @description:
  *   return the unit vector corresponding to a given angle. After the call,
  *   the value of "vec.x" will be "sin(theta)", and the value of "vec.y"
  *   will be "cos(angle)"
  *
  *   this function is useful to retrieve both the sinus and cosinus
  *   of a given angle quickly
  *
  * @input:
  *   vec   :: address of target vector
  *   angle :: address of angle
  */
  FT_EXPORT(void)        FT_Vector_Unit( FT_Vector*  vec,
                                         FT_Angle    angle );

 /***************************************************************************
  *
  * @function: FT_Vector_Rotate
  *
  * @description:
  *   rotate a given vector by a given angle
  *
  * @input:
  *   vec   :: address of target vector
  *   angle :: address of angle
  */
  FT_EXPORT(void)        FT_Vector_Rotate( FT_Vector*    vec,
                                           FT_Angle      angle );

 /***************************************************************************
  *
  * @function: FT_Vector_Length
  *
  * @description:
  *   returns the length of a given vector
  *
  * @input:
  *   vec   :: address of target vector
  *
  * @return:
  *   vector length, expressed in the same units that the original
  *   vector coordinates !!
  */
  FT_EXPORT(FT_Fixed)    FT_Vector_Length( FT_Vector*  vec );

 /***************************************************************************
  *
  * @function: FT_Vector_Normalize
  *
  * @description:
  *   normalize a given vector (i.e. compute the equivalent unit vector)
  *
  * @input:
  *   vec   :: address of target vector
  */
  FT_EXPORT(void)        FT_Vector_Normalize( FT_Vector*  vec );

 /***************************************************************************
  *
  * @function: FT_Vector_Polarize
  *
  * @description:
  *   compute both the length and angle of a given vector
  *
  * @input:
  *   vec    :: address of source vector
  *
  * @output:
  *   length :: vector length
  *   angle  :: vector angle
  */
  FT_EXPORT(void)        FT_Vector_Polarize( FT_Vector*  vec,
                                             FT_Fixed   *length,
                                             FT_Angle   *angle );
  /* */
  
FT_END_HEADER

#endif /* __FT_TRIGONOMETRY_H__ */