# | Line 69 | Line 69 | namespace oopse{ | |
---|---|---|
69 | ||
70 | /** Constructs and initializes a Quaternion from w, x, y, z values */ | |
71 | Quaternion(Real w, Real x, Real y, Real z) { | |
72 | < | data_[0] = w; |
73 | < | data_[1] = x; |
74 | < | data_[2] = y; |
75 | < | data_[3] = z; |
72 | > | this->data_[0] = w; |
73 | > | this->data_[1] = x; |
74 | > | this->data_[2] = y; |
75 | > | this->data_[3] = z; |
76 | } | |
77 | ||
78 | /** Constructs and initializes a Quaternion from a Vector<Real,4> */ | |
# | Line 95 | Line 95 | namespace oopse{ | |
95 | * @return the value of the first element of this quaternion | |
96 | */ | |
97 | Real w() const { | |
98 | < | return data_[0]; |
98 | > | return this->data_[0]; |
99 | } | |
100 | ||
101 | /** | |
# | Line 103 | Line 103 | namespace oopse{ | |
103 | * @return the reference of the first element of this quaternion | |
104 | */ | |
105 | Real& w() { | |
106 | < | return data_[0]; |
106 | > | return this->data_[0]; |
107 | } | |
108 | ||
109 | /** | |
# | Line 111 | Line 111 | namespace oopse{ | |
111 | * @return the value of the first element of this quaternion | |
112 | */ | |
113 | Real x() const { | |
114 | < | return data_[1]; |
114 | > | return this->data_[1]; |
115 | } | |
116 | ||
117 | /** | |
# | Line 119 | Line 119 | namespace oopse{ | |
119 | * @return the reference of the second element of this quaternion | |
120 | */ | |
121 | Real& x() { | |
122 | < | return data_[1]; |
122 | > | return this->data_[1]; |
123 | } | |
124 | ||
125 | /** | |
# | Line 127 | Line 127 | namespace oopse{ | |
127 | * @return the value of the third element of this quaternion | |
128 | */ | |
129 | Real y() const { | |
130 | < | return data_[2]; |
130 | > | return this->data_[2]; |
131 | } | |
132 | ||
133 | /** | |
# | Line 135 | Line 135 | namespace oopse{ | |
135 | * @return the reference of the third element of this quaternion | |
136 | */ | |
137 | Real& y() { | |
138 | < | return data_[2]; |
138 | > | return this->data_[2]; |
139 | } | |
140 | ||
141 | /** | |
# | Line 143 | Line 143 | namespace oopse{ | |
143 | * @return the value of the fourth element of this quaternion | |
144 | */ | |
145 | Real z() const { | |
146 | < | return data_[3]; |
146 | > | return this->data_[3]; |
147 | } | |
148 | /** | |
149 | * Returns the reference of the fourth element of this quaternion. | |
150 | * @return the reference of the fourth element of this quaternion | |
151 | */ | |
152 | Real& z() { | |
153 | < | return data_[3]; |
153 | > | return this->data_[3]; |
154 | } | |
155 | ||
156 | /** | |
# | Line 161 | Line 161 | namespace oopse{ | |
161 | inline bool operator ==(const Quaternion<Real>& q) { | |
162 | ||
163 | for (unsigned int i = 0; i < 4; i ++) { | |
164 | < | if (!equal(data_[i], q[i])) { |
164 | > | if (!equal(this->data_[i], q[i])) { |
165 | return false; | |
166 | } | |
167 | } | |
# | Line 194 | Line 194 | namespace oopse{ | |
194 | void mul(const Quaternion<Real>& q) { | |
195 | Quaternion<Real> tmp(*this); | |
196 | ||
197 | < | data_[0] = (tmp[0]*q[0]) -(tmp[1]*q[1]) - (tmp[2]*q[2]) - (tmp[3]*q[3]); |
198 | < | data_[1] = (tmp[0]*q[1]) + (tmp[1]*q[0]) + (tmp[2]*q[3]) - (tmp[3]*q[2]); |
199 | < | data_[2] = (tmp[0]*q[2]) + (tmp[2]*q[0]) + (tmp[3]*q[1]) - (tmp[1]*q[3]); |
200 | < | data_[3] = (tmp[0]*q[3]) + (tmp[3]*q[0]) + (tmp[1]*q[2]) - (tmp[2]*q[1]); |
197 | > | this->data_[0] = (tmp[0]*q[0]) -(tmp[1]*q[1]) - (tmp[2]*q[2]) - (tmp[3]*q[3]); |
198 | > | this->data_[1] = (tmp[0]*q[1]) + (tmp[1]*q[0]) + (tmp[2]*q[3]) - (tmp[3]*q[2]); |
199 | > | this->data_[2] = (tmp[0]*q[2]) + (tmp[2]*q[0]) + (tmp[3]*q[1]) - (tmp[1]*q[3]); |
200 | > | this->data_[3] = (tmp[0]*q[3]) + (tmp[3]*q[0]) + (tmp[1]*q[2]) - (tmp[2]*q[1]); |
201 | } | |
202 | ||
203 | void mul(const Real& s) { | |
204 | < | data_[0] *= s; |
205 | < | data_[1] *= s; |
206 | < | data_[2] *= s; |
207 | < | data_[3] *= s; |
204 | > | this->data_[0] *= s; |
205 | > | this->data_[1] *= s; |
206 | > | this->data_[2] *= s; |
207 | > | this->data_[3] *= s; |
208 | } | |
209 | ||
210 | /** Set the value of this quaternion to the division of itself by another quaternion */ | |
# | Line 213 | Line 213 | namespace oopse{ | |
213 | } | |
214 | ||
215 | void div(const Real& s) { | |
216 | < | data_[0] /= s; |
217 | < | data_[1] /= s; |
218 | < | data_[2] /= s; |
219 | < | data_[3] /= s; |
216 | > | this->data_[0] /= s; |
217 | > | this->data_[1] /= s; |
218 | > | this->data_[2] /= s; |
219 | > | this->data_[3] /= s; |
220 | } | |
221 | ||
222 | Quaternion<Real>& operator *=(const Quaternion<Real>& q) { | |
# | Line 258 | Line 258 | namespace oopse{ | |
258 | Real y2; | |
259 | Real z2; | |
260 | ||
261 | < | if (!isNormalized()) |
262 | < | normalize(); |
261 | > | if (!this->isNormalized()) |
262 | > | this->normalize(); |
263 | ||
264 | w2 = w() * w(); | |
265 | x2 = x() * x(); |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |