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