1 /***************************************************************************/
5 /* FreeType trigonometric functions (specification). */
7 /* Copyright 2001 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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. */
16 /***************************************************************************/
19 #ifndef __FTTRIGON_H__
20 #define __FTTRIGON_H__
22 #include FT_FREETYPE_H
28 /*************************************************************************/
33 /*************************************************************************/
36 /*************************************************************************/
42 /* This type is used to model angle values in FreeType. Note that */
43 /* the angle is a 16.16 fixed float value expressed in degrees. */
45 typedef FT_Fixed FT_Angle
;
48 /*************************************************************************/
54 /* The angle pi expressed in @FT_Angle units. */
56 #define FT_ANGLE_PI ( 180L << 16 )
59 /*************************************************************************/
65 /* The angle 2*pi expressed in @FT_Angle units. */
67 #define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 )
70 /*************************************************************************/
76 /* The angle pi/2 expressed in @FT_Angle units. */
78 #define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 )
81 /*************************************************************************/
87 /* The angle pi/4 expressed in @FT_Angle units. */
89 #define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 )
92 /*************************************************************************/
98 /* Return the sinus of a given angle in fixed point format. */
101 /* angle :: The input angle. */
104 /* The sinus value. */
107 /* If you need both the sinus and cosinus for a given angle, use the */
108 /* function @FT_Vector_Unit. */
110 FT_EXPORT( FT_Fixed
)
111 FT_Sin( FT_Angle angle
);
114 /*************************************************************************/
120 /* Return the cosinus of a given angle in fixed point format. */
123 /* angle :: The input angle. */
126 /* The cosinus value. */
129 /* If you need both the sinus and cosinus for a given angle, use the */
130 /* function @FT_Vector_Unit. */
132 FT_EXPORT( FT_Fixed
)
133 FT_Cos( FT_Angle angle
);
136 /*************************************************************************/
142 /* Return the tangent of a given angle in fixed point format. */
145 /* angle :: The input angle. */
148 /* The tangent value. */
150 FT_EXPORT( FT_Fixed
)
151 FT_Tan( FT_Angle angle
);
154 /*************************************************************************/
160 /* Return the arc-tangent corresponding to a given vector (x,y) in */
164 /* x :: The horizontal vector coordinate. */
166 /* y :: The vertical vector coordinate. */
169 /* The arc-tangent value (i.e. angle). */
171 FT_EXPORT( FT_Angle
)
172 FT_Atan2( FT_Fixed x
,
176 /*************************************************************************/
182 /* Return the unit vector corresponding to a given angle. After the */
183 /* call, the value of `vec.x' will be `sin(angle)', and the value of */
184 /* `vec.y' will be `cos(angle)'. */
186 /* This function is useful to retrieve both the sinus and cosinus of */
187 /* a given angle quickly. */
190 /* vec :: The address of target vector. */
193 /* angle :: The address of angle. */
196 FT_Vector_Unit( FT_Vector
* vec
,
200 /*************************************************************************/
203 /* FT_Vector_Rotate */
206 /* Rotate a vector by a given angle. */
209 /* vec :: The address of target vector. */
212 /* angle :: The address of angle. */
215 FT_Vector_Rotate( FT_Vector
* vec
,
219 /*************************************************************************/
222 /* FT_Vector_Length */
225 /* Return the length of a given vector. */
228 /* vec :: The address of target vector. */
231 /* The vector length, expressed in the same units that the original */
232 /* vector coordinates. */
234 FT_EXPORT( FT_Fixed
)
235 FT_Vector_Length( FT_Vector
* vec
);
238 /*************************************************************************/
241 /* FT_Vector_Normalize */
244 /* Normalize a given vector (i.e. compute the equivalent unit */
248 /* vec :: The address of target vector. */
251 FT_Vector_Normalize( FT_Vector
* vec
);
254 /*************************************************************************/
257 /* FT_Vector_Polarize */
260 /* Compute both the length and angle of a given vector. */
263 /* vec :: The address of source vector. */
266 /* length :: The vector length. */
267 /* angle :: The vector angle. */
270 FT_Vector_Polarize( FT_Vector
* vec
,
278 #endif /* __FTTRIGON_H__ */