Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 2, 2010, 3:16:08 AM (14 years ago)
Author:
landauf
Message:

added documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/doc/src/libraries/util/Math.h

    r7184 r7323  
    2828
    2929/**
     30   @defgroup Math Mathematical functions
     31   @ingroup Util
     32*/
     33
     34/**
    3035    @file
     36    @ingroup Util Math
    3137    @brief Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the orxonox namespace.
    3238*/
     
    6268    namespace math
    6369    {
    64         const float pi      = 3.14159265f;
    65         const float pi_2    = 1.57079633f;
    66         const float pi_4    = 7.85398163e-1f;
    67         const float e       = 2.71828183f;
    68         const float sqrt2   = 1.41421356f;
    69         const float sqrt2_2 = 7.07106781e-1f;
    70 
    71         const double pi_d      = 3.14159265358979324;
    72         const double pi_2_d    = 1.57079632679489662;
    73         const double pi_4_d    = 7.85398163397448310e-1;
    74         const double e_d       = 2.71828182845904524;
    75         const double sqrt2_d   = 1.41421356237309505;
    76         const double sqrt2_2_d = 7.07106781186547524e-1;
     70        const float pi      = 3.14159265f;      ///< PI
     71        const float pi_2    = 1.57079633f;      ///< PI / 2
     72        const float pi_4    = 7.85398163e-1f;   ///< PI / 4
     73        const float e       = 2.71828183f;      ///< e
     74        const float sqrt2   = 1.41421356f;      ///< sqrt(2)
     75        const float sqrt2_2 = 7.07106781e-1f;   ///< sqrt(2) / 2
     76
     77        const double pi_d      = 3.14159265358979324;       ///< PI (double)
     78        const double pi_2_d    = 1.57079632679489662;       ///< PI / 2 (double)
     79        const double pi_4_d    = 7.85398163397448310e-1;    ///< PI / 4 (double)
     80        const double e_d       = 2.71828182845904524;       ///< e (double)
     81        const double sqrt2_d   = 1.41421356237309505;       ///< sqrt(2) (double)
     82        const double sqrt2_2_d = 7.07106781186547524e-1;    ///< sqrt(2) / 2 (double)
    7783    }
    7884
     
    101107
    102108    /**
    103         @brief Keeps a value between a lower and an upper limit.
     109        @brief Keeps a value between a lower and an upper limit. Values beyond these limits are limited to either @a min or @a max.
    104110        @param x The value
    105111        @param min The lower limit
     
    119125
    120126    /**
    121         @brief Returns the square value (x^2).
     127        @brief Returns the squared value (x^2).
    122128    */
    123129    template <typename T>
     
    128134
    129135    /**
    130         @brief Returns the cube value (x^3).
     136        @brief Returns the cubed value (x^3).
    131137    */
    132138    template <typename T>
     
    137143
    138144    /**
    139         @brief Rounds the value.
     145        @brief Rounds the value to the nearest integer.
    140146    */
    141147    template <typename T>
     
    149155        @param x The value
    150156        @param max The operand
     157
     158        The built in modulo operator % yields a strange behavior with negative values.
     159        This function corrects this - the result is guaranteed to lie always between
     160        zero and (max-1).
     161
     162        Example:
     163        @code
     164        int var = 11 % 10;      //  1
     165        int var = -1 % 10;      // -1
     166
     167        int var = mod(11, 10);  //  1
     168        int var = mod(-1, 10);  //  9
     169        @endcode
    151170    */
    152171    template <typename T>
     
    159178    }
    160179
     180    /**
     181        @brief Returns a "zero" value for the given type.
     182        @note This is the default template of the zeroise() function. The template is spezialized for each supported type.
     183
     184        The exact return value of the function depends on the type. For @c int this is 0,
     185        for @c float it's 0.0f. For a @c std::string the function returns "" and for
     186        @c Vector3 you get <tt>Vector3(0, 0, 0)</tt>.
     187    */
    161188    template <typename T>
    162189    inline T zeroise()
     
    192219    template <> inline orxonox::Quaternion  zeroise<orxonox::Quaternion>()  { return orxonox::Quaternion (0, 0, 0, 0); }
    193220
    194     //! Provides zero value symbols that can be returned as reference
     221    /**
     222        @brief Provides zero value symbols that can be returned as reference
     223        @see zeroise()
     224    */
    195225    template <typename T>
    196226    struct NilValue
     
    207237    /**
    208238        @brief Interpolates between two values for a time between 0 and 1.
    209         @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates if time is between 0 and 1.
    210         @param start The value at time = 0
    211         @param end The value at time = 1
    212         @return The interpolation at a given time
     239        @param time The time is a value between 0 and 1 - the function returns @a start if @a time is 0, @a end if @a time is 1, and interpolates if @a time is between 0 and 1.
     240        @param start The value at @a time = 0
     241        @param end The value at @a time = 1
     242        @return The interpolated value at a given time
    213243    */
    214244    template <typename T>
     
    220250    /**
    221251        @brief Interpolates smoothly between two values for a time between 0 and 1. The function starts slowly, increases faster and stops slowly again.
    222         @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates if time is between 0 and 1.
    223         @param start The value at time = 0
    224         @param end The value at time = 1
    225         @return The smoothed interpolation at a given time
     252        @param time The time is a value between 0 and 1 - the function returns @a start if @a time is 0, @a end if @a time is 1, and interpolates if @a time is between 0 and 1.
     253        @param start The value at @a time = 0
     254        @param end The value at @a time = 1
     255        @return The interpolated value at a given time
    226256    */
    227257    template <typename T>
     
    232262
    233263    /**
    234         @brief Returns a random number between 0 and almost 1: 0 <= rnd < 1.
     264        @brief Returns a random number between 0 and almost 1: <tt>0 <= rnd < 1</tt>.
    235265    */
    236266    inline float rnd()
     
    240270
    241271    /**
    242         @brief Returns a random number between 0 and almost max: 0 <= rnd < max.
     272        @brief Returns a random number between 0 and almost @a max: <tt>0 <= rnd < max</tt>.
    243273        @param max The maximum
    244274    */
     
    249279
    250280    /**
    251         @brief Returns a random number between min and almost max: min <= rnd < max.
     281        @brief Returns a random number between @a min and almost @a max: <tt>min <= rnd < max</tt>.
    252282        @param min The minimum
    253283        @param max The maximum
     
    268298    _UtilExport unsigned long getUniqueNumber();
    269299
     300    /**
     301        @brief A Vector class containing two integers @a x and @a y.
     302    */
    270303    class IntVector2
    271304    {
     
    277310    };
    278311
     312    /**
     313        @brief A Vector class containing three integers @a x, @a y, and @a z.
     314    */
    279315    class IntVector3
    280316    {
Note: See TracChangeset for help on using the changeset viewer.