1/*---------------------------------------------------------------------------*
2  Project:  Horizon
3  File:     math_Vector3.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: 13623 $
14 *---------------------------------------------------------------------------*/
15
16#include <cmath>
17
18namespace nn {
19namespace math {
20namespace ARMv6 {
21/* ------------------------------------------------------------------------
22        VEC3
23   ------------------------------------------------------------------------ */
24
25/* Please see man pages for details
26
27
28*/
29
30/*
31
32
33
34
35
36
37 */
38NN_MATH_INLINE VEC3*
39VEC3NormalizeC(VEC3* pOut, const VEC3* p)
40{
41    NN_NULL_ASSERT(pOut);
42    NN_NULL_ASSERT(p);
43
44    f32 mag = (p->x * p->x) + (p->y * p->y) + (p->z * p->z);
45
46    NN_ASSERTMSG(mag != 0, "MATHNormalize3():  zero magnitude vector");
47
48    mag = 1.0f / ::std::sqrtf(mag);
49
50    pOut->x = p->x * mag;
51    pOut->y = p->y * mag;
52    pOut->z = p->z * mag;
53
54    return pOut;
55}
56
57
58NN_MATH_INLINE VEC3*
59VEC3NormalizeC_FAST(VEC3* pOut, const VEC3* p)
60{
61    NN_NULL_ASSERT(pOut);
62    NN_NULL_ASSERT(p);
63
64    register f32 x, y, z, mag;
65
66    x = p->x;
67    y = p->y;
68    z = p->z;
69
70    mag = (x * x) + (y * y) + (z * z);
71
72    NN_ASSERTMSG(mag != 0, "MATHNormalize3():  zero magnitude vector");
73
74    mag = 1.0f / ::std::sqrtf(mag);
75
76    x *= mag;
77    y *= mag;
78    z *= mag;
79
80    pOut->x = x;
81    pOut->y = y;
82    pOut->z = z;
83
84    return pOut;
85}
86
87
88/*
89
90*/
91}  // namespcae ARMv6
92}  // namespace math
93}  // namespace nn
94