CTR Pia  4.11.3
Game Communication Engine
reckoning_Vector3f.h
1 /*---------------------------------------------------------------------------*
2  Project: Pia
3  File: reckoning_Vector3f.h
4 
5  Copyright Nintendo. 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 
14 
15 #pragma once
16 
17 #include <pia/reckoning/reckoning_definitions.h>
18 
19 
20 namespace nn
21 {
22 namespace pia
23 {
24 namespace reckoning
25 {
26 
27 /*!
28 @brief The <tt>Vector3f</tt> class provides functionality for the strategy used to handle 3D vectors.
29 
30 @date 2013-10-29 Initial version.
31 */
32 class Vector3f
33 {
34 public:
35  f32 x, y, z;
36 
37 /*!
38 @brief Instantiates the object with default parameters (default constructor).
39 */
41  : x(0.f), y(0.f), z(0.f) {};
42 
43 /*!
44 @brief Instantiates the object and initializes the element with the specified arguments.
45 @param[in] x, y, z Specifies the values to use for initialization.
46 */
47  Vector3f(const f32 x, const f32 y, const f32 z)
48  {
49  this->x = x;
50  this->y = y;
51  this->z = z;
52  }
53 
54 /*!
55 @brief Sets the zero vector.
56 */
57  void MakeZero()
58  {
59  x = y = z = 0.f;
60  }
61 
62 /*!
63 @brief Gets the square of the distance between two points.
64 @param[in] v Specifies the vector to find the distance of.
65 @return Returns the square of the distance.
66 */
67  f32 SquaredDistance(const Vector3f& v) const
68  {
69  f32 dx = this->x - v.x;
70  f32 dy = this->y - v.y;
71  f32 dz = this->z - v.z;
72  return dx * dx + dy * dy + dz * dz;
73  }
74 
75 /*!
76 @brief Adds the specified vector to the target vector.
77 @param[out] out Stores the target vector.
78 @param[in] v Specifies the vector to add.
79 */
80  static void Add(Vector3f* out, const Vector3f& v)
81  {
82  out->x += v.x;
83  out->y += v.y;
84  out->z += v.z;
85  return;
86  }
87 
88 /*!
89 @brief Multiplies the target vector by the specified scalar value.
90 @param[out] out Stores the target vector.
91 @param[in] t Specifies the scalar value.
92 */
93  static void Mul(Vector3f* out, const f32& t)
94  {
95  out->x *= t;
96  out->y *= t;
97  out->z *= t;
98  }
99 
100 /*!
101 @brief Adds the specified vector and assigns the result.
102 @param[in] v Specifies the vector to add.
103 @return Returns the vector after addition.
104 */
106  {
107  x += v.x;
108  y += v.y;
109  z += v.z;
110  return *this;
111  }
112 
113 /*!
114 @brief Divides by the specified scalar value and assigns the result.
115 @param[in] t Specifies the value to divide by.
116 @return Returns the vector after division.
117 */
118  Vector3f& operator/=(const f32& t)
119  {
120  x /= t;
121  y /= t;
122  z /= t;
123  return *this;
124  }
125 
126 protected:
127 private:
128 };
129 }
130 }
131 } // end of namespace nn::pia::reckoning
void MakeZero()
Sets the zero vector.
Definition: reckoning_Vector3f.h:57
Vector3f & operator/=(const f32 &t)
Divides by the specified scalar value and assigns the result.
Definition: reckoning_Vector3f.h:118
f32 SquaredDistance(const Vector3f &v) const
Gets the square of the distance between two points.
Definition: reckoning_Vector3f.h:67
Vector3f & operator+=(const Vector3f &v)
Adds the specified vector and assigns the result.
Definition: reckoning_Vector3f.h:105
Definition: assert.h:115
static void Add(Vector3f *out, const Vector3f &v)
Adds the specified vector to the target vector.
Definition: reckoning_Vector3f.h:80
The Vector3f class provides functionality for the strategy used to handle 3D vectors.
Definition: reckoning_Vector3f.h:32
Vector3f(const f32 x, const f32 y, const f32 z)
Instantiates the object and initializes the element with the specified arguments. ...
Definition: reckoning_Vector3f.h:47
static void Mul(Vector3f *out, const f32 &t)
Multiplies the target vector by the specified scalar value.
Definition: reckoning_Vector3f.h:93
Vector3f()
Instantiates the object with default parameters (default constructor).
Definition: reckoning_Vector3f.h:40