1/*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: math_Matrix43.ipp 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Revision: 17112 $ 14 *---------------------------------------------------------------------------*/ 15#include <nn/math/math_Matrix43.h> 16 17namespace nn { namespace math { 18 19/*! 20 @name 行列 21 @{ 22*/ 23 24/*!--------------------------------------------------------------------------* 25 @brief 行列が単位行列かどうか判定します。 26 27 @param[in] p 判定対象の行列へのポインタ。 28 29 @return p が単位行列であれば true そうでなければ false を返します。 30 *---------------------------------------------------------------------------*/ 31NN_MATH_INLINE bool 32MTX43IsIdentity(const MTX43* p) 33{ 34 return p->f._00 == 1.f && p->f._01 == 0.f && p->f._02 == 0.f && 35 p->f._10 == 0.f && p->f._11 == 1.f && p->f._12 == 0.f && 36 p->f._20 == 0.f && p->f._21 == 0.f && p->f._22 == 1.f && 37 p->f._30 == 0.f && p->f._31 == 0.f && p->f._32 == 0.f; 38} 39 40/*!--------------------------------------------------------------------------* 41 @brief 零行列を作成します。 42 43 @param[out] pOut 零行列を格納するバッファへのポインタ。 44 45 @return pOut を返します。 46 *---------------------------------------------------------------------------*/ 47NN_MATH_INLINE MTX43* 48MTX43Zero(MTX43* pOut) 49{ 50 NN_NULL_ASSERT( pOut ); 51 52 pOut->f._00 = pOut->f._01 = pOut->f._02 = 53 pOut->f._10 = pOut->f._11 = pOut->f._12 = 54 pOut->f._20 = pOut->f._21 = pOut->f._22 = 55 pOut->f._30 = pOut->f._31 = pOut->f._32 = 0.f; 56 57 return pOut; 58} 59 60/*!--------------------------------------------------------------------------* 61 @brief 単位行列を作成します。 62 63 @param[out] pOut 単位行列を格納するバッファへのポインタ。 64 65 @return pOut を返します。 66 *---------------------------------------------------------------------------*/ 67NN_MATH_INLINE MTX43* 68MTX43Identity(MTX43* pOut) 69{ 70 NN_NULL_ASSERT( pOut ); 71 72 MTX43Copy(pOut, MTX43::Identity()); 73 74 return pOut; 75} 76 77/*!--------------------------------------------------------------------------* 78 @brief 行列の差を計算します。 79 80 @param[out] pOut 計算結果を受け取るバッファへのポインタ。p1, p2 と同じ行列を指していても構いません。 81 @param[in] p1 左辺値へのポインタ。 82 @param[in] p2 右辺値へのポインタ。 83 84 @return pOut を返します。 85 *---------------------------------------------------------------------------*/ 86NN_MATH_INLINE MTX43* 87MTX43Sub(MTX43* pOut, const MTX43* p1, const MTX43* p2) 88{ 89 NN_NULL_ASSERT( pOut ); 90 NN_NULL_ASSERT( p1 ); 91 NN_NULL_ASSERT( p2 ); 92 93 pOut->f._00 = p1->f._00 - p2->f._00; 94 pOut->f._01 = p1->f._01 - p2->f._01; 95 pOut->f._02 = p1->f._02 - p2->f._02; 96 97 pOut->f._10 = p1->f._10 - p2->f._10; 98 pOut->f._11 = p1->f._11 - p2->f._11; 99 pOut->f._12 = p1->f._12 - p2->f._12; 100 101 pOut->f._20 = p1->f._20 - p2->f._20; 102 pOut->f._21 = p1->f._21 - p2->f._21; 103 pOut->f._22 = p1->f._22 - p2->f._22; 104 105 pOut->f._30 = p1->f._30 - p2->f._30; 106 pOut->f._31 = p1->f._31 - p2->f._31; 107 pOut->f._32 = p1->f._32 - p2->f._32; 108 109 return pOut; 110} 111 112 113/*! 114 @} 115*/ 116 117} // namespace math 118} // namespace nn 119