• メインページ
  • クラス
  • ファイル
  • ファイル一覧
  • ファイルメンバ

narMath.h

00001 /*-----------------------------------------------------------------------*
00002   Project:  Nintendo Augmented Reality Library.
00003   File:     narMath.h
00004 
00005   Copyright (C)2011-2012 Nintendo Co., Ltd.  All rights reserved.
00006 
00007   These coded instructions, statements, and computer programs contain
00008   proprietary information of Nintendo and/or its licensed developers
00009   and are protected by national and international copyright laws. They
00010   may not be disclosed to third parties or copied or duplicated in any
00011   form, in whole or in part, without the prior written consent of
00012   Nintendo.
00013   The content herein is highly confidential and should be handled
00014   accordingly.
00015 *-----------------------------------------------------------------------*/
00016 
00018 
00023 #ifndef NAR_MATH_H__
00024 #define NAR_MATH_H__
00025 
00026 #include <math.h>
00027 
00028 #include "narConfig.h"
00029 
00030 #ifdef NAR_CTR__
00031 #include <nn/math.h>
00032 #endif
00033 
00034 namespace mw { namespace nar
00035 {
00036     //=====================================================================
00040     inline f32 Sqrt( f32 x )
00041     {
00042         return ::std::sqrtf( x );
00043     }
00044     //=====================================================================
00048     inline f32 Cbrt( f32 x )
00049     {
00050 #ifdef NAR_CTR__
00051         return nn::math::FCbrt( x );
00052 #endif
00053     }
00054     //=====================================================================
00058     inline f32 Sin( f32 rad )
00059     {
00060 #ifdef NAR_CTR__
00061         return nn::math::SinRad( rad );
00062 #endif
00063     }
00064     //=====================================================================
00068     inline f32 Cos( f32 rad )
00069     {
00070 #ifdef NAR_CTR__
00071         return nn::math::CosRad( rad );
00072 #endif
00073     }
00074     //=====================================================================
00078     inline f32 ACos( f32 x )
00079     {
00080         return ::std::acos( x );
00081     }
00082     //=====================================================================
00086     template < typename T >
00087     inline T Pow2( T x )
00088     {
00089         return x * x;
00090     }
00091     //=====================================================================
00095     template < typename T >
00096     inline T Pow3( T x )
00097     {
00098         return x * x * x;
00099     }
00100 
00101     //=====================================================================
00105     inline int Abs( int x )
00106     {
00107         return x < 0 ? -x : x;
00108     }
00109     inline f32 Abs( f32 x )
00110     {
00111         return ::std::fabsf( x );
00112     }
00113     //=====================================================================
00117     template < typename T >
00118     inline T Max( T a, T b )
00119     {
00120         return a > b ? a : b;
00121     }
00122     //=====================================================================
00126     template < typename T >
00127     inline T Min( T a, T b )
00128     {
00129         return a < b ? a : b;
00130     }
00131     //=====================================================================
00135     extern const f32 c_Epsilon;
00136     extern const f32 c_NearThreshold;
00137 }
00138 }
00139 #endif
00140 

© 2011-2012 Nintendo Co., Ltd. All rights reserved.