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 difference between two angles. The result is always */
183 /* constrained to the ]-PI..PI] interval. */
186 /* angle1 :: First angle. */
188 /* angle2 :: Second angle. */
191 /* Contrainted value of `value2-value1'. */
193 FT_EXPORT( FT_Angle )
194 FT_Angle_Diff( FT_Angle angle1,
198 /*************************************************************************/
204 /* Return the unit vector corresponding to a given angle. After the */
205 /* call, the value of `vec.x' will be `sin(angle)', and the value of */
206 /* `vec.y' will be `cos(angle)'. */
208 /* This function is useful to retrieve both the sinus and cosinus of */
209 /* a given angle quickly. */
212 /* vec :: The address of target vector. */
215 /* angle :: The address of angle. */
218 FT_Vector_Unit( FT_Vector* vec,
222 /*************************************************************************/
225 /* FT_Vector_Rotate */
228 /* Rotate a vector by a given angle. */
231 /* vec :: The address of target vector. */
234 /* angle :: The address of angle. */
237 FT_Vector_Rotate( FT_Vector* vec,
241 /*************************************************************************/
244 /* FT_Vector_Length */
247 /* Return the length of a given vector. */
250 /* vec :: The address of target vector. */
253 /* The vector length, expressed in the same units that the original */
254 /* vector coordinates. */
256 FT_EXPORT( FT_Fixed )
257 FT_Vector_Length( FT_Vector* vec );
260 /*************************************************************************/
263 /* FT_Vector_Normalize */
266 /* Normalize a given vector (i.e. compute the equivalent unit */
270 /* vec :: The address of target vector. */
273 FT_Vector_Normalize( FT_Vector* vec );
276 /*************************************************************************/
279 /* FT_Vector_Polarize */
282 /* Compute both the length and angle of a given vector. */
285 /* vec :: The address of source vector. */
288 /* length :: The vector length. */
289 /* angle :: The vector angle. */
292 FT_Vector_Polarize( FT_Vector* vec,
297 /*************************************************************************/
300 /* FT_Vector_From_Polar */
303 /* Compute vector coordinates from a length and angle. */
306 /* vec :: The address of source vector. */
309 /* length :: The vector length. */
310 /* angle :: The vector angle. */
313 FT_Vector_From_Polar( FT_Vector* vec,
322 #endif /* __FTTRIGON_H__ */