
#ifndef __WFX_MATH_MATH_H__
#define __WFX_MATH_MATH_H__

#include <WFX/WFXIncludes.h>
#include <WFX/lang/Singleton.h>

namespace WFX {

    namespace math {

        /**
         * this class contains static wrapper functions for
         * standard math. this may come in handy if we might
         * one day want to use faster math functions than 
         * standard libc functions
         */
        class Math : public WFX::lang::Singleton<Math> {
            public:
                static const Real INF;
                static const Real PI;
                static const Real HALF_PI;

                inline static Real abs(Real r) {
                    return fabs(r);
                }
                inline static Real sqrt(Real r) {
                    return sqrtf(r);
                }
                inline static Real sin(Real r) {
                    return sinf(r);
                }
                inline static Real cos(Real r) {
                    return cosf(r);
                }
                inline static Real tan(Real r) {
                    return tanf(r);
                }
                inline static Real asin(Real r) {
                    return asinf(r);
                }
                inline static Real acos(Real r) {
                    return acosf(r);
                }
                inline static Real atan(Real r) {
                    return atanf(r);
                }
                inline static Real atan2(Real r1, Real r2) {
                    return atan2f(r1,r2);
                }
                inline static Real rad2deg(Real r) {
                    static Real Rad2DegFactor = Math::PI/Real(180);
                    return r * Rad2DegFactor;
                }
                inline static Real deg2rad(Real r) {
                    static Real Deg2RadFactor = Real(180)/Math::PI;
                    return r * Deg2RadFactor;
                }

                /** returns first power of 2 >= a */
                inline static Int nextP2(Int a) {
                    Int ret = 1;
                    while (ret <a)
                        ret <<= 1;
                    return ret;
                }

            
            protected:
               
                
                
        };

    }

}


#endif //include guard


