1/*---------------------------------------------------------------------------*
2  Project:  Horizon
3  File:     math_Matrix22.ipp
4  Copyright (C)2009-2010 Nintendo Co., Ltd.  All rights reserved.
5  These coded instructions, statements, and computer programs contain
6  proprietary information of Nintendo of America Inc. and/or Nintendo
7  Company Ltd., and are protected by Federal copyright law. They may
8  not be disclosed to third parties or copied or duplicated in any form,
9  in whole or in part, without the prior written consent of Nintendo.
10  $Revision: 13623 $
11 *---------------------------------------------------------------------------
12
13
14*/
15namespace nn {
16namespace math {
17
18/* ------------------------------------------------------------------------
19        MTX22
20   ------------------------------------------------------------------------ */
21/* Please see man pages for details
22
23
24*/
25
26/*
27
28
29
30
31
32*/
33NN_MATH_INLINE bool
34MTX22IsIdentity(const MTX22* p)
35{
36    return p->f._00 == 1.f && p->f._01 == 0.f &&
37           p->f._10 == 0.f && p->f._11 == 1.f;
38}
39
40/*
41
42
43
44
45
46
47*/
48NN_MATH_INLINE MTX22*
49MTX22Copy(MTX22* pOut, const MTX22* p)
50{
51    NN_NULL_ASSERT( pOut );
52    NN_NULL_ASSERT( p );
53
54    if (pOut != p)
55    {
56        *pOut = *p;
57    }
58
59    return pOut;
60}
61
62/*
63
64
65
66
67
68*/
69NN_MATH_INLINE MTX22*
70MTX22Zero(MTX22* pOut)
71{
72    NN_NULL_ASSERT( pOut );
73
74    pOut->f._00 = pOut->f._01 =
75    pOut->f._10 = pOut->f._11 = 0.f;
76    return pOut;
77}
78
79/*
80
81
82
83
84
85*/
86NN_MATH_INLINE MTX22*
87MTX22Identity(MTX22* pOut)
88{
89    NN_NULL_ASSERT( pOut );
90
91    MTX22Copy(pOut, MTX22::Identity());
92
93    return pOut;
94}
95
96/*
97
98
99
100
101
102
103
104
105*/
106NN_MATH_INLINE MTX22*
107MTX22MAdd(MTX22* pOut, f32 t, const MTX22* p1, const MTX22* p2)
108{
109    NN_NULL_ASSERT( pOut );
110    NN_NULL_ASSERT( p1 );
111    NN_NULL_ASSERT( p2 );
112
113    pOut->f._00 = t * p1->f._00 + p2->f._00;
114    pOut->f._01 = t * p1->f._01 + p2->f._01;
115
116    pOut->f._10 = t * p1->f._10 + p2->f._10;
117    pOut->f._11 = t * p1->f._11 + p2->f._11;
118
119    return pOut;
120}
121
122/*
123
124*/
125
126}  // namespace math
127}  // namespace nn
128