rev |
line source |
nuclear@0
|
1 /***************************************************************************/
|
nuclear@0
|
2 /* */
|
nuclear@0
|
3 /* fttrigon.h */
|
nuclear@0
|
4 /* */
|
nuclear@0
|
5 /* FreeType trigonometric functions (specification). */
|
nuclear@0
|
6 /* */
|
nuclear@0
|
7 /* Copyright 2001, 2003, 2005, 2007 by */
|
nuclear@0
|
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
nuclear@0
|
9 /* */
|
nuclear@0
|
10 /* This file is part of the FreeType project, and may only be used, */
|
nuclear@0
|
11 /* modified, and distributed under the terms of the FreeType project */
|
nuclear@0
|
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
nuclear@0
|
13 /* this file you indicate that you have read the license and */
|
nuclear@0
|
14 /* understand and accept it fully. */
|
nuclear@0
|
15 /* */
|
nuclear@0
|
16 /***************************************************************************/
|
nuclear@0
|
17
|
nuclear@0
|
18
|
nuclear@0
|
19 #ifndef __FTTRIGON_H__
|
nuclear@0
|
20 #define __FTTRIGON_H__
|
nuclear@0
|
21
|
nuclear@0
|
22 #include FT_FREETYPE_H
|
nuclear@0
|
23
|
nuclear@0
|
24 #ifdef FREETYPE_H
|
nuclear@0
|
25 #error "freetype.h of FreeType 1 has been loaded!"
|
nuclear@0
|
26 #error "Please fix the directory search order for header files"
|
nuclear@0
|
27 #error "so that freetype.h of FreeType 2 is found first."
|
nuclear@0
|
28 #endif
|
nuclear@0
|
29
|
nuclear@0
|
30
|
nuclear@0
|
31 FT_BEGIN_HEADER
|
nuclear@0
|
32
|
nuclear@0
|
33
|
nuclear@0
|
34 /*************************************************************************/
|
nuclear@0
|
35 /* */
|
nuclear@0
|
36 /* <Section> */
|
nuclear@0
|
37 /* computations */
|
nuclear@0
|
38 /* */
|
nuclear@0
|
39 /*************************************************************************/
|
nuclear@0
|
40
|
nuclear@0
|
41
|
nuclear@0
|
42 /*************************************************************************
|
nuclear@0
|
43 *
|
nuclear@0
|
44 * @type:
|
nuclear@0
|
45 * FT_Angle
|
nuclear@0
|
46 *
|
nuclear@0
|
47 * @description:
|
nuclear@0
|
48 * This type is used to model angle values in FreeType. Note that the
|
nuclear@0
|
49 * angle is a 16.16 fixed float value expressed in degrees.
|
nuclear@0
|
50 *
|
nuclear@0
|
51 */
|
nuclear@0
|
52 typedef FT_Fixed FT_Angle;
|
nuclear@0
|
53
|
nuclear@0
|
54
|
nuclear@0
|
55 /*************************************************************************
|
nuclear@0
|
56 *
|
nuclear@0
|
57 * @macro:
|
nuclear@0
|
58 * FT_ANGLE_PI
|
nuclear@0
|
59 *
|
nuclear@0
|
60 * @description:
|
nuclear@0
|
61 * The angle pi expressed in @FT_Angle units.
|
nuclear@0
|
62 *
|
nuclear@0
|
63 */
|
nuclear@0
|
64 #define FT_ANGLE_PI ( 180L << 16 )
|
nuclear@0
|
65
|
nuclear@0
|
66
|
nuclear@0
|
67 /*************************************************************************
|
nuclear@0
|
68 *
|
nuclear@0
|
69 * @macro:
|
nuclear@0
|
70 * FT_ANGLE_2PI
|
nuclear@0
|
71 *
|
nuclear@0
|
72 * @description:
|
nuclear@0
|
73 * The angle 2*pi expressed in @FT_Angle units.
|
nuclear@0
|
74 *
|
nuclear@0
|
75 */
|
nuclear@0
|
76 #define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 )
|
nuclear@0
|
77
|
nuclear@0
|
78
|
nuclear@0
|
79 /*************************************************************************
|
nuclear@0
|
80 *
|
nuclear@0
|
81 * @macro:
|
nuclear@0
|
82 * FT_ANGLE_PI2
|
nuclear@0
|
83 *
|
nuclear@0
|
84 * @description:
|
nuclear@0
|
85 * The angle pi/2 expressed in @FT_Angle units.
|
nuclear@0
|
86 *
|
nuclear@0
|
87 */
|
nuclear@0
|
88 #define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 )
|
nuclear@0
|
89
|
nuclear@0
|
90
|
nuclear@0
|
91 /*************************************************************************
|
nuclear@0
|
92 *
|
nuclear@0
|
93 * @macro:
|
nuclear@0
|
94 * FT_ANGLE_PI4
|
nuclear@0
|
95 *
|
nuclear@0
|
96 * @description:
|
nuclear@0
|
97 * The angle pi/4 expressed in @FT_Angle units.
|
nuclear@0
|
98 *
|
nuclear@0
|
99 */
|
nuclear@0
|
100 #define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 )
|
nuclear@0
|
101
|
nuclear@0
|
102
|
nuclear@0
|
103 /*************************************************************************
|
nuclear@0
|
104 *
|
nuclear@0
|
105 * @function:
|
nuclear@0
|
106 * FT_Sin
|
nuclear@0
|
107 *
|
nuclear@0
|
108 * @description:
|
nuclear@0
|
109 * Return the sinus of a given angle in fixed point format.
|
nuclear@0
|
110 *
|
nuclear@0
|
111 * @input:
|
nuclear@0
|
112 * angle ::
|
nuclear@0
|
113 * The input angle.
|
nuclear@0
|
114 *
|
nuclear@0
|
115 * @return:
|
nuclear@0
|
116 * The sinus value.
|
nuclear@0
|
117 *
|
nuclear@0
|
118 * @note:
|
nuclear@0
|
119 * If you need both the sinus and cosinus for a given angle, use the
|
nuclear@0
|
120 * function @FT_Vector_Unit.
|
nuclear@0
|
121 *
|
nuclear@0
|
122 */
|
nuclear@0
|
123 FT_EXPORT( FT_Fixed )
|
nuclear@0
|
124 FT_Sin( FT_Angle angle );
|
nuclear@0
|
125
|
nuclear@0
|
126
|
nuclear@0
|
127 /*************************************************************************
|
nuclear@0
|
128 *
|
nuclear@0
|
129 * @function:
|
nuclear@0
|
130 * FT_Cos
|
nuclear@0
|
131 *
|
nuclear@0
|
132 * @description:
|
nuclear@0
|
133 * Return the cosinus of a given angle in fixed point format.
|
nuclear@0
|
134 *
|
nuclear@0
|
135 * @input:
|
nuclear@0
|
136 * angle ::
|
nuclear@0
|
137 * The input angle.
|
nuclear@0
|
138 *
|
nuclear@0
|
139 * @return:
|
nuclear@0
|
140 * The cosinus value.
|
nuclear@0
|
141 *
|
nuclear@0
|
142 * @note:
|
nuclear@0
|
143 * If you need both the sinus and cosinus for a given angle, use the
|
nuclear@0
|
144 * function @FT_Vector_Unit.
|
nuclear@0
|
145 *
|
nuclear@0
|
146 */
|
nuclear@0
|
147 FT_EXPORT( FT_Fixed )
|
nuclear@0
|
148 FT_Cos( FT_Angle angle );
|
nuclear@0
|
149
|
nuclear@0
|
150
|
nuclear@0
|
151 /*************************************************************************
|
nuclear@0
|
152 *
|
nuclear@0
|
153 * @function:
|
nuclear@0
|
154 * FT_Tan
|
nuclear@0
|
155 *
|
nuclear@0
|
156 * @description:
|
nuclear@0
|
157 * Return the tangent of a given angle in fixed point format.
|
nuclear@0
|
158 *
|
nuclear@0
|
159 * @input:
|
nuclear@0
|
160 * angle ::
|
nuclear@0
|
161 * The input angle.
|
nuclear@0
|
162 *
|
nuclear@0
|
163 * @return:
|
nuclear@0
|
164 * The tangent value.
|
nuclear@0
|
165 *
|
nuclear@0
|
166 */
|
nuclear@0
|
167 FT_EXPORT( FT_Fixed )
|
nuclear@0
|
168 FT_Tan( FT_Angle angle );
|
nuclear@0
|
169
|
nuclear@0
|
170
|
nuclear@0
|
171 /*************************************************************************
|
nuclear@0
|
172 *
|
nuclear@0
|
173 * @function:
|
nuclear@0
|
174 * FT_Atan2
|
nuclear@0
|
175 *
|
nuclear@0
|
176 * @description:
|
nuclear@0
|
177 * Return the arc-tangent corresponding to a given vector (x,y) in
|
nuclear@0
|
178 * the 2d plane.
|
nuclear@0
|
179 *
|
nuclear@0
|
180 * @input:
|
nuclear@0
|
181 * x ::
|
nuclear@0
|
182 * The horizontal vector coordinate.
|
nuclear@0
|
183 *
|
nuclear@0
|
184 * y ::
|
nuclear@0
|
185 * The vertical vector coordinate.
|
nuclear@0
|
186 *
|
nuclear@0
|
187 * @return:
|
nuclear@0
|
188 * The arc-tangent value (i.e. angle).
|
nuclear@0
|
189 *
|
nuclear@0
|
190 */
|
nuclear@0
|
191 FT_EXPORT( FT_Angle )
|
nuclear@0
|
192 FT_Atan2( FT_Fixed x,
|
nuclear@0
|
193 FT_Fixed y );
|
nuclear@0
|
194
|
nuclear@0
|
195
|
nuclear@0
|
196 /*************************************************************************
|
nuclear@0
|
197 *
|
nuclear@0
|
198 * @function:
|
nuclear@0
|
199 * FT_Angle_Diff
|
nuclear@0
|
200 *
|
nuclear@0
|
201 * @description:
|
nuclear@0
|
202 * Return the difference between two angles. The result is always
|
nuclear@0
|
203 * constrained to the ]-PI..PI] interval.
|
nuclear@0
|
204 *
|
nuclear@0
|
205 * @input:
|
nuclear@0
|
206 * angle1 ::
|
nuclear@0
|
207 * First angle.
|
nuclear@0
|
208 *
|
nuclear@0
|
209 * angle2 ::
|
nuclear@0
|
210 * Second angle.
|
nuclear@0
|
211 *
|
nuclear@0
|
212 * @return:
|
nuclear@0
|
213 * Constrained value of `value2-value1'.
|
nuclear@0
|
214 *
|
nuclear@0
|
215 */
|
nuclear@0
|
216 FT_EXPORT( FT_Angle )
|
nuclear@0
|
217 FT_Angle_Diff( FT_Angle angle1,
|
nuclear@0
|
218 FT_Angle angle2 );
|
nuclear@0
|
219
|
nuclear@0
|
220
|
nuclear@0
|
221 /*************************************************************************
|
nuclear@0
|
222 *
|
nuclear@0
|
223 * @function:
|
nuclear@0
|
224 * FT_Vector_Unit
|
nuclear@0
|
225 *
|
nuclear@0
|
226 * @description:
|
nuclear@0
|
227 * Return the unit vector corresponding to a given angle. After the
|
nuclear@0
|
228 * call, the value of `vec.x' will be `sin(angle)', and the value of
|
nuclear@0
|
229 * `vec.y' will be `cos(angle)'.
|
nuclear@0
|
230 *
|
nuclear@0
|
231 * This function is useful to retrieve both the sinus and cosinus of a
|
nuclear@0
|
232 * given angle quickly.
|
nuclear@0
|
233 *
|
nuclear@0
|
234 * @output:
|
nuclear@0
|
235 * vec ::
|
nuclear@0
|
236 * The address of target vector.
|
nuclear@0
|
237 *
|
nuclear@0
|
238 * @input:
|
nuclear@0
|
239 * angle ::
|
nuclear@0
|
240 * The address of angle.
|
nuclear@0
|
241 *
|
nuclear@0
|
242 */
|
nuclear@0
|
243 FT_EXPORT( void )
|
nuclear@0
|
244 FT_Vector_Unit( FT_Vector* vec,
|
nuclear@0
|
245 FT_Angle angle );
|
nuclear@0
|
246
|
nuclear@0
|
247
|
nuclear@0
|
248 /*************************************************************************
|
nuclear@0
|
249 *
|
nuclear@0
|
250 * @function:
|
nuclear@0
|
251 * FT_Vector_Rotate
|
nuclear@0
|
252 *
|
nuclear@0
|
253 * @description:
|
nuclear@0
|
254 * Rotate a vector by a given angle.
|
nuclear@0
|
255 *
|
nuclear@0
|
256 * @inout:
|
nuclear@0
|
257 * vec ::
|
nuclear@0
|
258 * The address of target vector.
|
nuclear@0
|
259 *
|
nuclear@0
|
260 * @input:
|
nuclear@0
|
261 * angle ::
|
nuclear@0
|
262 * The address of angle.
|
nuclear@0
|
263 *
|
nuclear@0
|
264 */
|
nuclear@0
|
265 FT_EXPORT( void )
|
nuclear@0
|
266 FT_Vector_Rotate( FT_Vector* vec,
|
nuclear@0
|
267 FT_Angle angle );
|
nuclear@0
|
268
|
nuclear@0
|
269
|
nuclear@0
|
270 /*************************************************************************
|
nuclear@0
|
271 *
|
nuclear@0
|
272 * @function:
|
nuclear@0
|
273 * FT_Vector_Length
|
nuclear@0
|
274 *
|
nuclear@0
|
275 * @description:
|
nuclear@0
|
276 * Return the length of a given vector.
|
nuclear@0
|
277 *
|
nuclear@0
|
278 * @input:
|
nuclear@0
|
279 * vec ::
|
nuclear@0
|
280 * The address of target vector.
|
nuclear@0
|
281 *
|
nuclear@0
|
282 * @return:
|
nuclear@0
|
283 * The vector length, expressed in the same units that the original
|
nuclear@0
|
284 * vector coordinates.
|
nuclear@0
|
285 *
|
nuclear@0
|
286 */
|
nuclear@0
|
287 FT_EXPORT( FT_Fixed )
|
nuclear@0
|
288 FT_Vector_Length( FT_Vector* vec );
|
nuclear@0
|
289
|
nuclear@0
|
290
|
nuclear@0
|
291 /*************************************************************************
|
nuclear@0
|
292 *
|
nuclear@0
|
293 * @function:
|
nuclear@0
|
294 * FT_Vector_Polarize
|
nuclear@0
|
295 *
|
nuclear@0
|
296 * @description:
|
nuclear@0
|
297 * Compute both the length and angle of a given vector.
|
nuclear@0
|
298 *
|
nuclear@0
|
299 * @input:
|
nuclear@0
|
300 * vec ::
|
nuclear@0
|
301 * The address of source vector.
|
nuclear@0
|
302 *
|
nuclear@0
|
303 * @output:
|
nuclear@0
|
304 * length ::
|
nuclear@0
|
305 * The vector length.
|
nuclear@0
|
306 *
|
nuclear@0
|
307 * angle ::
|
nuclear@0
|
308 * The vector angle.
|
nuclear@0
|
309 *
|
nuclear@0
|
310 */
|
nuclear@0
|
311 FT_EXPORT( void )
|
nuclear@0
|
312 FT_Vector_Polarize( FT_Vector* vec,
|
nuclear@0
|
313 FT_Fixed *length,
|
nuclear@0
|
314 FT_Angle *angle );
|
nuclear@0
|
315
|
nuclear@0
|
316
|
nuclear@0
|
317 /*************************************************************************
|
nuclear@0
|
318 *
|
nuclear@0
|
319 * @function:
|
nuclear@0
|
320 * FT_Vector_From_Polar
|
nuclear@0
|
321 *
|
nuclear@0
|
322 * @description:
|
nuclear@0
|
323 * Compute vector coordinates from a length and angle.
|
nuclear@0
|
324 *
|
nuclear@0
|
325 * @output:
|
nuclear@0
|
326 * vec ::
|
nuclear@0
|
327 * The address of source vector.
|
nuclear@0
|
328 *
|
nuclear@0
|
329 * @input:
|
nuclear@0
|
330 * length ::
|
nuclear@0
|
331 * The vector length.
|
nuclear@0
|
332 *
|
nuclear@0
|
333 * angle ::
|
nuclear@0
|
334 * The vector angle.
|
nuclear@0
|
335 *
|
nuclear@0
|
336 */
|
nuclear@0
|
337 FT_EXPORT( void )
|
nuclear@0
|
338 FT_Vector_From_Polar( FT_Vector* vec,
|
nuclear@0
|
339 FT_Fixed length,
|
nuclear@0
|
340 FT_Angle angle );
|
nuclear@0
|
341
|
nuclear@0
|
342 /* */
|
nuclear@0
|
343
|
nuclear@0
|
344
|
nuclear@0
|
345 FT_END_HEADER
|
nuclear@0
|
346
|
nuclear@0
|
347 #endif /* __FTTRIGON_H__ */
|
nuclear@0
|
348
|
nuclear@0
|
349
|
nuclear@0
|
350 /* END */
|