3b8257b6d61fc53f3e881671f092425ecaaea074
[reactos.git] / lib / freetype / include / freetype / fttrigon.h
1 /***************************************************************************/
2 /*                                                                         */
3 /*  fttrigon.h                                                             */
4 /*                                                                         */
5 /*    FreeType trigonometric functions (specification).                    */
6 /*                                                                         */
7 /*  Copyright 2001 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
19 #ifndef __FTTRIGON_H__
20 #define __FTTRIGON_H__
21
22 #include FT_FREETYPE_H
23
24
25 FT_BEGIN_HEADER
26
27
28   /*************************************************************************/
29   /*                                                                       */
30   /* @section:                                                             */
31   /*   computations                                                        */
32   /*                                                                       */
33   /*************************************************************************/
34
35
36   /*************************************************************************/
37   /*                                                                       */
38   /* @type:                                                                */
39   /*    FT_Angle                                                           */
40   /*                                                                       */
41   /* @description:                                                         */
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.       */
44   /*                                                                       */
45   typedef FT_Fixed  FT_Angle;
46
47
48   /*************************************************************************/
49   /*                                                                       */
50   /* @macro:                                                               */
51   /*    FT_ANGLE_PI                                                        */
52   /*                                                                       */
53   /* @description:                                                         */
54   /*   The angle pi expressed in @FT_Angle units.                          */
55   /*                                                                       */
56 #define FT_ANGLE_PI  ( 180L << 16 )
57
58
59   /*************************************************************************/
60   /*                                                                       */
61   /* @macro:                                                               */
62   /*    FT_ANGLE_2PI                                                       */
63   /*                                                                       */
64   /* @description:                                                         */
65   /*    The angle 2*pi expressed in @FT_Angle units.                       */
66   /*                                                                       */
67 #define FT_ANGLE_2PI  ( FT_ANGLE_PI * 2 )
68
69
70   /*************************************************************************/
71   /*                                                                       */
72   /* @macro:                                                               */
73   /*    FT_ANGLE_PI2                                                       */
74   /*                                                                       */
75   /* @description:                                                         */
76   /*    The angle pi/2 expressed in @FT_Angle units.                       */
77   /*                                                                       */
78 #define FT_ANGLE_PI2  ( FT_ANGLE_PI / 2 )
79
80
81   /*************************************************************************/
82   /*                                                                       */
83   /* @macro:                                                               */
84   /*    FT_ANGLE_PI4                                                       */
85   /*                                                                       */
86   /* @description:                                                         */
87   /*    The angle pi/4 expressed in @FT_Angle units.                       */
88   /*                                                                       */
89 #define FT_ANGLE_PI4  ( FT_ANGLE_PI / 4 )
90
91
92   /*************************************************************************/
93   /*                                                                       */
94   /* @function:                                                            */
95   /*    FT_Sin                                                             */
96   /*                                                                       */
97   /* @description:                                                         */
98   /*    Return the sinus of a given angle in fixed point format.           */
99   /*                                                                       */
100   /* @input:                                                               */
101   /*    angle :: The input angle.                                          */
102   /*                                                                       */
103   /* @return:                                                              */
104   /*    The sinus value.                                                   */
105   /*                                                                       */
106   /* @note:                                                                */
107   /*    If you need both the sinus and cosinus for a given angle, use the  */
108   /*    function @FT_Vector_Unit.                                          */
109   /*                                                                       */
110   FT_EXPORT( FT_Fixed )
111   FT_Sin( FT_Angle  angle );
112
113
114   /*************************************************************************/
115   /*                                                                       */
116   /* @function:                                                            */
117   /*    FT_Cos                                                             */
118   /*                                                                       */
119   /* @description:                                                         */
120   /*    Return the cosinus of a given angle in fixed point format.         */
121   /*                                                                       */
122   /* @input:                                                               */
123   /*    angle :: The input angle.                                          */
124   /*                                                                       */
125   /* @return:                                                              */
126   /*    The cosinus value.                                                 */
127   /*                                                                       */
128   /* @note:                                                                */
129   /*    If you need both the sinus and cosinus for a given angle, use the  */
130   /*    function @FT_Vector_Unit.                                          */
131   /*                                                                       */
132   FT_EXPORT( FT_Fixed )
133   FT_Cos( FT_Angle  angle );
134
135
136   /*************************************************************************/
137   /*                                                                       */
138   /* @function:                                                            */
139   /*    FT_Tan                                                             */
140   /*                                                                       */
141   /* @description:                                                         */
142   /*    Return the tangent of a given angle in fixed point format.         */
143   /*                                                                       */
144   /* @input:                                                               */
145   /*    angle :: The input angle.                                          */
146   /*                                                                       */
147   /* @return:                                                              */
148   /*    The tangent value.                                                 */
149   /*                                                                       */
150   FT_EXPORT( FT_Fixed )
151   FT_Tan( FT_Angle  angle );
152
153
154   /*************************************************************************/
155   /*                                                                       */
156   /* @function:                                                            */
157   /*    FT_Atan2                                                           */
158   /*                                                                       */
159   /* @description:                                                         */
160   /*    Return the arc-tangent corresponding to a given vector (x,y) in    */
161   /*    the 2d plane.                                                      */
162   /*                                                                       */
163   /* @input:                                                               */
164   /*    x :: The horizontal vector coordinate.                             */
165   /*                                                                       */
166   /*    y :: The vertical vector coordinate.                               */
167   /*                                                                       */
168   /* @return:                                                              */
169   /*    The arc-tangent value (i.e. angle).                                */
170   /*                                                                       */
171   FT_EXPORT( FT_Angle )
172   FT_Atan2( FT_Fixed  x,
173             FT_Fixed  y );
174
175
176   /*************************************************************************/
177   /*                                                                       */
178   /* @function:                                                            */
179   /*    FT_Angle_Diff                                                      */
180   /*                                                                       */
181   /* @description:                                                         */
182   /*    Return the difference between two angles.  The result is always    */
183   /*    constrained to the ]-PI..PI] interval.                             */
184   /*                                                                       */
185   /* @input:                                                               */
186   /*    angle1 :: First angle.                                             */
187   /*                                                                       */
188   /*    angle2 :: Second angle.                                            */
189   /*                                                                       */
190   /* @return:                                                              */
191   /*    Contrainted value of `value2-value1'.                              */
192   /*                                                                       */
193   FT_EXPORT( FT_Angle )
194   FT_Angle_Diff( FT_Angle  angle1,
195                  FT_Angle  angle2 );
196
197
198   /*************************************************************************/
199   /*                                                                       */
200   /* @function:                                                            */
201   /*    FT_Vector_Unit                                                     */
202   /*                                                                       */
203   /* @description:                                                         */
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)'.                                      */
207   /*                                                                       */
208   /*    This function is useful to retrieve both the sinus and cosinus of  */
209   /*    a given angle quickly.                                             */
210   /*                                                                       */
211   /* @output:                                                              */
212   /*    vec   :: The address of target vector.                             */
213   /*                                                                       */
214   /* @input:                                                               */
215   /*    angle :: The address of angle.                                     */
216   /*                                                                       */
217   FT_EXPORT( void )
218   FT_Vector_Unit( FT_Vector*  vec,
219                   FT_Angle    angle );
220
221
222   /*************************************************************************/
223   /*                                                                       */
224   /* @function:                                                            */
225   /*    FT_Vector_Rotate                                                   */
226   /*                                                                       */
227   /* @description:                                                         */
228   /*    Rotate a vector by a given angle.                                  */
229   /*                                                                       */
230   /* @inout:                                                               */
231   /*    vec   :: The address of target vector.                             */
232   /*                                                                       */
233   /* @input:                                                               */
234   /*    angle :: The address of angle.                                     */
235   /*                                                                       */
236   FT_EXPORT( void )
237   FT_Vector_Rotate( FT_Vector*  vec,
238                     FT_Angle    angle );
239
240
241   /*************************************************************************/
242   /*                                                                       */
243   /* @function:                                                            */
244   /*   FT_Vector_Length                                                    */
245   /*                                                                       */
246   /* @description:                                                         */
247   /*   Return the length of a given vector.                                */
248   /*                                                                       */
249   /* @input:                                                               */
250   /*   vec :: The address of target vector.                                */
251   /*                                                                       */
252   /* @return:                                                              */
253   /*   The vector length, expressed in the same units that the original    */
254   /*   vector coordinates.                                                 */
255   /*                                                                       */
256   FT_EXPORT( FT_Fixed )
257   FT_Vector_Length( FT_Vector*  vec );
258
259
260   /*************************************************************************/
261   /*                                                                       */
262   /* @function:                                                            */
263   /*    FT_Vector_Normalize                                                */
264   /*                                                                       */
265   /* @description:                                                         */
266   /*    Normalize a given vector (i.e. compute the equivalent unit         */
267   /*    vector).                                                           */
268   /*                                                                       */
269   /* @inout:                                                               */
270   /*    vec :: The address of target vector.                               */
271   /*                                                                       */
272   FT_EXPORT( void )
273   FT_Vector_Normalize( FT_Vector*  vec );
274
275
276   /*************************************************************************/
277   /*                                                                       */
278   /* @function:                                                            */
279   /*    FT_Vector_Polarize                                                 */
280   /*                                                                       */
281   /* @description:                                                         */
282   /*    Compute both the length and angle of a given vector.               */
283   /*                                                                       */
284   /* @input:                                                               */
285   /*    vec    :: The address of source vector.                            */
286   /*                                                                       */
287   /* @output:                                                              */
288   /*    length :: The vector length.                                       */
289   /*    angle  :: The vector angle.                                        */
290   /*                                                                       */
291   FT_EXPORT( void )
292   FT_Vector_Polarize( FT_Vector*  vec,
293                       FT_Fixed   *length,
294                       FT_Angle   *angle );
295
296
297   /*************************************************************************/
298   /*                                                                       */
299   /* @function:                                                            */
300   /*    FT_Vector_From_Polar                                               */
301   /*                                                                       */
302   /* @description:                                                         */
303   /*    Compute vector coordinates from a length and angle.                */
304   /*                                                                       */
305   /* @output:                                                              */
306   /*    vec    :: The address of source vector.                            */
307   /*                                                                       */
308   /* @input:                                                               */
309   /*    length :: The vector length.                                       */
310   /*    angle  :: The vector angle.                                        */
311   /*                                                                       */
312   FT_EXPORT( void )
313   FT_Vector_From_Polar( FT_Vector*  vec,
314                         FT_Fixed    length,
315                         FT_Angle    angle );
316
317   /* */
318
319
320 FT_END_HEADER
321
322 #endif /* __FTTRIGON_H__ */
323
324
325 /* END */