/*---------------------------------------------------------------------------* Project: Horizon File: math_Arithmetic.h Copyright (C)2009-2010 Nintendo Co., Ltd. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Revision: 17112 $ *---------------------------------------------------------------------------*/ #ifndef NN_MATH_ARMV6_MATH_ARITHMETIC_H_ #define NN_MATH_ARMV6_MATH_ARITHMETIC_H_ #include #include #include #include namespace nn { namespace math { namespace ARMv6 { /* ======================================================================= 浮動少数に関する数学関数 ======================================================================== */ /*! @name 浮動小数に関する数学関数 @{ */ //! @details :private f32 HermiteAsm(f32 v0, f32 t0, f32 v1, f32 t1, f32 s); f32 HermiteAsm(f32 v0, f32 t0, f32 v1, f32 t1, f32 p, f32 d); /*!--------------------------------------------------------------------------* @brief エルミート補間を行います @param[in] v0 点1での値。 @param[in] t0 点1での傾き。 @param[in] v1 点2での値。 @param[in] t1 点2での傾き。 @param[in] s 補間対象位置。(点1:0.0~1.0:点2) @return 補間結果の値。 *---------------------------------------------------------------------------*/ inline f32 HermiteC(f32 v0, f32 t0, f32 v1, f32 t1, f32 s) { f32 SS = s * s; f32 SS_S = s * s - s; f32 b1 = SS_S * s - SS_S; f32 b2 = SS_S * s; f32 a2 = SS - 2.f * b2; return v0 - a2 * v0 + a2 * v1 + b1 * t0 + b2 * t1; } inline f32 HermiteC_FAST(f32 v0, f32 t0, f32 v1, f32 t1, f32 s) { f32 SS; f32 SS_S; f32 b1; f32 b2; f32 a2; SS = s * s; SS_S = s * s - s; b2 = SS_S * s; b1 = b2 - SS_S; a2 = SS - 2.f * b2; return v0 - a2 * v0 + a2 * v1 + b1 * t0 + b2 * t1; } /*!--------------------------------------------------------------------------* @brief エルミート補間計算です。 @param[in] v0 点1での値。 @param[in] t0 点1での傾き。 @param[in] v1 点2での値。 @param[in] t1 点2での傾き。 @param[in] p 点1から補間対象位置の距離。 @param[in] d 点1と点2の距離。 @return エルミート補間の結果です。 *---------------------------------------------------------------------------*/ inline f32 HermiteC(f32 v0, f32 t0, f32 v1, f32 t1, f32 p, f32 d) { f32 inv_d = 1 / d; f32 s = p * inv_d; f32 s_1 = s - 1; return v0 + (v0 - v1) * (2 * s - 3) * s * s + p * s_1 * (s_1 * t0 + s * t1); } inline f32 HermiteC_FAST(f32 v0, f32 t0, f32 v1, f32 t1, f32 p, f32 d) { f32 s = p / d; f32 s_1 = s - 1; f32 tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, ret; tmp1 = (v0 - v1); tmp2 = (2 * s - 3); tmp3 = s * s; tmp4 = p * s_1; tmp5 = s_1 * t0; tmp6 = s * t1; ret = v0 + tmp1 * tmp2 * tmp3 + tmp4 * (tmp5 + tmp6); return ret; } /*! @} */ }}} // nn::math::ARMv6 /* NN_MATH_ARMV6_MATH_ARITHMETIC_H_ */ #endif