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