1
/***************************************************************************/
5
/* FreeType trigonometric functions (specification). */
7
/* Copyright 2001, 2003 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
25
#error "freetype.h of FreeType 1 has been loaded!"
26
#error "Please fix the directory search order for header files"
27
#error "so that freetype.h of FreeType 2 is found first."
34
/*************************************************************************/
39
/*************************************************************************/
42
/*************************************************************************/
48
/* This type is used to model angle values in FreeType. Note that */
49
/* the angle is a 16.16 fixed float value expressed in degrees. */
51
typedef FT_Fixed FT_Angle;
54
/*************************************************************************/
60
/* The angle pi expressed in @FT_Angle units. */
62
#define FT_ANGLE_PI ( 180L << 16 )
65
/*************************************************************************/
71
/* The angle 2*pi expressed in @FT_Angle units. */
73
#define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 )
76
/*************************************************************************/
82
/* The angle pi/2 expressed in @FT_Angle units. */
84
#define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 )
87
/*************************************************************************/
93
/* The angle pi/4 expressed in @FT_Angle units. */
95
#define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 )
98
/*************************************************************************/
104
/* Return the sinus of a given angle in fixed point format. */
107
/* angle :: The input angle. */
110
/* The sinus value. */
113
/* If you need both the sinus and cosinus for a given angle, use the */
114
/* function @FT_Vector_Unit. */
116
FT_EXPORT( FT_Fixed )
117
FT_Sin( FT_Angle angle );
120
/*************************************************************************/
126
/* Return the cosinus of a given angle in fixed point format. */
129
/* angle :: The input angle. */
132
/* The cosinus value. */
135
/* If you need both the sinus and cosinus for a given angle, use the */
136
/* function @FT_Vector_Unit. */
138
FT_EXPORT( FT_Fixed )
139
FT_Cos( FT_Angle angle );
142
/*************************************************************************/
148
/* Return the tangent of a given angle in fixed point format. */
151
/* angle :: The input angle. */
154
/* The tangent value. */
156
FT_EXPORT( FT_Fixed )
157
FT_Tan( FT_Angle angle );
160
/*************************************************************************/
166
/* Return the arc-tangent corresponding to a given vector (x,y) in */
170
/* x :: The horizontal vector coordinate. */
172
/* y :: The vertical vector coordinate. */
175
/* The arc-tangent value (i.e. angle). */
177
FT_EXPORT( FT_Angle )
178
FT_Atan2( FT_Fixed x,
182
/*************************************************************************/
188
/* Return the difference between two angles. The result is always */
189
/* constrained to the ]-PI..PI] interval. */
192
/* angle1 :: First angle. */
194
/* angle2 :: Second angle. */
197
/* Contrainted value of `value2-value1'. */
199
FT_EXPORT( FT_Angle )
200
FT_Angle_Diff( FT_Angle angle1,
204
/*************************************************************************/
210
/* Return the unit vector corresponding to a given angle. After the */
211
/* call, the value of `vec.x' will be `sin(angle)', and the value of */
212
/* `vec.y' will be `cos(angle)'. */
214
/* This function is useful to retrieve both the sinus and cosinus of */
215
/* a given angle quickly. */
218
/* vec :: The address of target vector. */
221
/* angle :: The address of angle. */
224
FT_Vector_Unit( FT_Vector* vec,
228
/*************************************************************************/
231
/* FT_Vector_Rotate */
234
/* Rotate a vector by a given angle. */
237
/* vec :: The address of target vector. */
240
/* angle :: The address of angle. */
243
FT_Vector_Rotate( FT_Vector* vec,
247
/*************************************************************************/
250
/* FT_Vector_Length */
253
/* Return the length of a given vector. */
256
/* vec :: The address of target vector. */
259
/* The vector length, expressed in the same units that the original */
260
/* vector coordinates. */
262
FT_EXPORT( FT_Fixed )
263
FT_Vector_Length( FT_Vector* vec );
266
/*************************************************************************/
269
/* FT_Vector_Polarize */
272
/* Compute both the length and angle of a given vector. */
275
/* vec :: The address of source vector. */
278
/* length :: The vector length. */
279
/* angle :: The vector angle. */
282
FT_Vector_Polarize( FT_Vector* vec,
287
/*************************************************************************/
290
/* FT_Vector_From_Polar */
293
/* Compute vector coordinates from a length and angle. */
296
/* vec :: The address of source vector. */
299
/* length :: The vector length. */
300
/* angle :: The vector angle. */
303
FT_Vector_From_Polar( FT_Vector* vec,
312
#endif /* __FTTRIGON_H__ */