1/*---------------------------------------------------------------------------*
2  Project:  Horizon
3  File:     math_Matrix22.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: 45840 $
14 *---------------------------------------------------------------------------*/
15namespace nn {
16namespace math {
17
18/* ------------------------------------------------------------------------
19        MTX22
20   ------------------------------------------------------------------------ */
21NN_MATH_INLINE MTX22*
22MTX22Copy(MTX22* pOut, const MTX22* p)
23{
24    NN_NULL_ASSERT( pOut );
25    NN_NULL_ASSERT( p );
26
27    if (pOut != p)
28    {
29        *pOut = *p;
30    }
31
32    return pOut;
33}
34
35NN_MATH_INLINE MTX22*
36MTX22Identity(MTX22* pOut)
37{
38    NN_NULL_ASSERT( pOut );
39
40    MTX22Copy(pOut, MTX22::Identity());
41
42    return pOut;
43}
44
45NN_MATH_INLINE bool
46MTX22IsIdentity(const MTX22* p)
47{
48    return p->f._00 == 1.f && p->f._01 == 0.f &&
49           p->f._10 == 0.f && p->f._11 == 1.f;
50}
51
52NN_MATH_INLINE MTX22*
53MTX22MAdd(MTX22* pOut, f32 t, const MTX22* p1, const MTX22* p2)
54{
55    NN_NULL_ASSERT( pOut );
56    NN_NULL_ASSERT( p1 );
57    NN_NULL_ASSERT( p2 );
58
59    pOut->f._00 = t * p1->f._00 + p2->f._00;
60    pOut->f._01 = t * p1->f._01 + p2->f._01;
61
62    pOut->f._10 = t * p1->f._10 + p2->f._10;
63    pOut->f._11 = t * p1->f._11 + p2->f._11;
64
65    return pOut;
66}
67
68NN_MATH_INLINE MTX22*
69MTX22Zero(MTX22* pOut)
70{
71    NN_NULL_ASSERT( pOut );
72
73    pOut->f._00 = pOut->f._01 =
74    pOut->f._10 = pOut->f._11 = 0.f;
75    return pOut;
76}
77
78}  // namespace math
79}  // namespace nn
80