michael@0: /***************************************************************************/ michael@0: /* */ michael@0: /* fttrigon.h */ michael@0: /* */ michael@0: /* FreeType trigonometric functions (specification). */ michael@0: /* */ michael@0: /* Copyright 2001, 2003, 2005, 2007, 2013 by */ michael@0: /* David Turner, Robert Wilhelm, and Werner Lemberg. */ michael@0: /* */ michael@0: /* This file is part of the FreeType project, and may only be used, */ michael@0: /* modified, and distributed under the terms of the FreeType project */ michael@0: /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ michael@0: /* this file you indicate that you have read the license and */ michael@0: /* understand and accept it fully. */ michael@0: /* */ michael@0: /***************************************************************************/ michael@0: michael@0: michael@0: #ifndef __FTTRIGON_H__ michael@0: #define __FTTRIGON_H__ michael@0: michael@0: #include FT_FREETYPE_H michael@0: michael@0: #ifdef FREETYPE_H michael@0: #error "freetype.h of FreeType 1 has been loaded!" michael@0: #error "Please fix the directory search order for header files" michael@0: #error "so that freetype.h of FreeType 2 is found first." michael@0: #endif michael@0: michael@0: michael@0: FT_BEGIN_HEADER michael@0: michael@0: michael@0: /*************************************************************************/ michael@0: /* */ michael@0: /*
*/ michael@0: /* computations */ michael@0: /* */ michael@0: /*************************************************************************/ michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @type: michael@0: * FT_Angle michael@0: * michael@0: * @description: michael@0: * This type is used to model angle values in FreeType. Note that the michael@0: * angle is a 16.16 fixed-point value expressed in degrees. michael@0: * michael@0: */ michael@0: typedef FT_Fixed FT_Angle; michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @macro: michael@0: * FT_ANGLE_PI michael@0: * michael@0: * @description: michael@0: * The angle pi expressed in @FT_Angle units. michael@0: * michael@0: */ michael@0: #define FT_ANGLE_PI ( 180L << 16 ) michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @macro: michael@0: * FT_ANGLE_2PI michael@0: * michael@0: * @description: michael@0: * The angle 2*pi expressed in @FT_Angle units. michael@0: * michael@0: */ michael@0: #define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 ) michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @macro: michael@0: * FT_ANGLE_PI2 michael@0: * michael@0: * @description: michael@0: * The angle pi/2 expressed in @FT_Angle units. michael@0: * michael@0: */ michael@0: #define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 ) michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @macro: michael@0: * FT_ANGLE_PI4 michael@0: * michael@0: * @description: michael@0: * The angle pi/4 expressed in @FT_Angle units. michael@0: * michael@0: */ michael@0: #define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 ) michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @function: michael@0: * FT_Sin michael@0: * michael@0: * @description: michael@0: * Return the sinus of a given angle in fixed-point format. michael@0: * michael@0: * @input: michael@0: * angle :: michael@0: * The input angle. michael@0: * michael@0: * @return: michael@0: * The sinus value. michael@0: * michael@0: * @note: michael@0: * If you need both the sinus and cosinus for a given angle, use the michael@0: * function @FT_Vector_Unit. michael@0: * michael@0: */ michael@0: FT_EXPORT( FT_Fixed ) michael@0: FT_Sin( FT_Angle angle ); michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @function: michael@0: * FT_Cos michael@0: * michael@0: * @description: michael@0: * Return the cosinus of a given angle in fixed-point format. michael@0: * michael@0: * @input: michael@0: * angle :: michael@0: * The input angle. michael@0: * michael@0: * @return: michael@0: * The cosinus value. michael@0: * michael@0: * @note: michael@0: * If you need both the sinus and cosinus for a given angle, use the michael@0: * function @FT_Vector_Unit. michael@0: * michael@0: */ michael@0: FT_EXPORT( FT_Fixed ) michael@0: FT_Cos( FT_Angle angle ); michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @function: michael@0: * FT_Tan michael@0: * michael@0: * @description: michael@0: * Return the tangent of a given angle in fixed-point format. michael@0: * michael@0: * @input: michael@0: * angle :: michael@0: * The input angle. michael@0: * michael@0: * @return: michael@0: * The tangent value. michael@0: * michael@0: */ michael@0: FT_EXPORT( FT_Fixed ) michael@0: FT_Tan( FT_Angle angle ); michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @function: michael@0: * FT_Atan2 michael@0: * michael@0: * @description: michael@0: * Return the arc-tangent corresponding to a given vector (x,y) in michael@0: * the 2d plane. michael@0: * michael@0: * @input: michael@0: * x :: michael@0: * The horizontal vector coordinate. michael@0: * michael@0: * y :: michael@0: * The vertical vector coordinate. michael@0: * michael@0: * @return: michael@0: * The arc-tangent value (i.e. angle). michael@0: * michael@0: */ michael@0: FT_EXPORT( FT_Angle ) michael@0: FT_Atan2( FT_Fixed x, michael@0: FT_Fixed y ); michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @function: michael@0: * FT_Angle_Diff michael@0: * michael@0: * @description: michael@0: * Return the difference between two angles. The result is always michael@0: * constrained to the ]-PI..PI] interval. michael@0: * michael@0: * @input: michael@0: * angle1 :: michael@0: * First angle. michael@0: * michael@0: * angle2 :: michael@0: * Second angle. michael@0: * michael@0: * @return: michael@0: * Constrained value of `value2-value1'. michael@0: * michael@0: */ michael@0: FT_EXPORT( FT_Angle ) michael@0: FT_Angle_Diff( FT_Angle angle1, michael@0: FT_Angle angle2 ); michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @function: michael@0: * FT_Vector_Unit michael@0: * michael@0: * @description: michael@0: * Return the unit vector corresponding to a given angle. After the michael@0: * call, the value of `vec.x' will be `sin(angle)', and the value of michael@0: * `vec.y' will be `cos(angle)'. michael@0: * michael@0: * This function is useful to retrieve both the sinus and cosinus of a michael@0: * given angle quickly. michael@0: * michael@0: * @output: michael@0: * vec :: michael@0: * The address of target vector. michael@0: * michael@0: * @input: michael@0: * angle :: michael@0: * The address of angle. michael@0: * michael@0: */ michael@0: FT_EXPORT( void ) michael@0: FT_Vector_Unit( FT_Vector* vec, michael@0: FT_Angle angle ); michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @function: michael@0: * FT_Vector_Rotate michael@0: * michael@0: * @description: michael@0: * Rotate a vector by a given angle. michael@0: * michael@0: * @inout: michael@0: * vec :: michael@0: * The address of target vector. michael@0: * michael@0: * @input: michael@0: * angle :: michael@0: * The address of angle. michael@0: * michael@0: */ michael@0: FT_EXPORT( void ) michael@0: FT_Vector_Rotate( FT_Vector* vec, michael@0: FT_Angle angle ); michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @function: michael@0: * FT_Vector_Length michael@0: * michael@0: * @description: michael@0: * Return the length of a given vector. michael@0: * michael@0: * @input: michael@0: * vec :: michael@0: * The address of target vector. michael@0: * michael@0: * @return: michael@0: * The vector length, expressed in the same units that the original michael@0: * vector coordinates. michael@0: * michael@0: */ michael@0: FT_EXPORT( FT_Fixed ) michael@0: FT_Vector_Length( FT_Vector* vec ); michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @function: michael@0: * FT_Vector_Polarize michael@0: * michael@0: * @description: michael@0: * Compute both the length and angle of a given vector. michael@0: * michael@0: * @input: michael@0: * vec :: michael@0: * The address of source vector. michael@0: * michael@0: * @output: michael@0: * length :: michael@0: * The vector length. michael@0: * michael@0: * angle :: michael@0: * The vector angle. michael@0: * michael@0: */ michael@0: FT_EXPORT( void ) michael@0: FT_Vector_Polarize( FT_Vector* vec, michael@0: FT_Fixed *length, michael@0: FT_Angle *angle ); michael@0: michael@0: michael@0: /************************************************************************* michael@0: * michael@0: * @function: michael@0: * FT_Vector_From_Polar michael@0: * michael@0: * @description: michael@0: * Compute vector coordinates from a length and angle. michael@0: * michael@0: * @output: michael@0: * vec :: michael@0: * The address of source vector. michael@0: * michael@0: * @input: michael@0: * length :: michael@0: * The vector length. michael@0: * michael@0: * angle :: michael@0: * The vector angle. michael@0: * michael@0: */ michael@0: FT_EXPORT( void ) michael@0: FT_Vector_From_Polar( FT_Vector* vec, michael@0: FT_Fixed length, michael@0: FT_Angle angle ); michael@0: michael@0: /* */ michael@0: michael@0: michael@0: FT_END_HEADER michael@0: michael@0: #endif /* __FTTRIGON_H__ */ michael@0: michael@0: michael@0: /* END */