/src/assimp/contrib/Open3DGC/o3dgcVector.inl
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | Copyright (c) 2013 Khaled Mammou - Advanced Micro Devices, Inc. |
3 | | |
4 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
5 | | of this software and associated documentation files (the "Software"), to deal |
6 | | in the Software without restriction, including without limitation the rights |
7 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
8 | | copies of the Software, and to permit persons to whom the Software is |
9 | | furnished to do so, subject to the following conditions: |
10 | | |
11 | | The above copyright notice and this permission notice shall be included in |
12 | | all copies or substantial portions of the Software. |
13 | | |
14 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
15 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
16 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
17 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
18 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
19 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
20 | | THE SOFTWARE. |
21 | | */ |
22 | | |
23 | | #pragma once |
24 | | #ifndef O3DGC_VECTOR_INL |
25 | | #define O3DGC_VECTOR_INL |
26 | | namespace o3dgc |
27 | | { |
28 | | template <typename T> |
29 | | inline Vec3<T> operator*(T lhs, const Vec3<T> & rhs) |
30 | | { |
31 | | return Vec3<T>(lhs * rhs.X(), lhs * rhs.Y(), lhs * rhs.Z()); |
32 | | } |
33 | | template <typename T> |
34 | | inline T & Vec3<T>::X() |
35 | 0 | { |
36 | 0 | return m_data[0]; |
37 | 0 | } Unexecuted instantiation: o3dgc::Vec3<long>::X() Unexecuted instantiation: o3dgc::Vec3<float>::X() |
38 | | template <typename T> |
39 | | inline T & Vec3<T>::Y() |
40 | 0 | { |
41 | 0 | return m_data[1]; |
42 | 0 | } Unexecuted instantiation: o3dgc::Vec3<long>::Y() Unexecuted instantiation: o3dgc::Vec3<float>::Y() |
43 | | template <typename T> |
44 | | inline T & Vec3<T>::Z() |
45 | 0 | { |
46 | 0 | return m_data[2]; |
47 | 0 | } Unexecuted instantiation: o3dgc::Vec3<long>::Z() Unexecuted instantiation: o3dgc::Vec3<float>::Z() |
48 | | template <typename T> |
49 | | inline const T & Vec3<T>::X() const |
50 | | { |
51 | | return m_data[0]; |
52 | | } |
53 | | template <typename T> |
54 | | inline const T & Vec3<T>::Y() const |
55 | | { |
56 | | return m_data[1]; |
57 | | } |
58 | | template <typename T> |
59 | | inline const T & Vec3<T>::Z() const |
60 | | { |
61 | | return m_data[2]; |
62 | | } |
63 | | template <typename T> |
64 | | inline double Vec3<T>::GetNorm() const |
65 | 0 | { |
66 | 0 | double a = (double) (m_data[0]); |
67 | 0 | double b = (double) (m_data[1]); |
68 | 0 | double c = (double) (m_data[2]); |
69 | 0 | return sqrt(a*a+b*b+c*c); |
70 | 0 | } Unexecuted instantiation: o3dgc::Vec3<long>::GetNorm() const Unexecuted instantiation: o3dgc::Vec3<float>::GetNorm() const |
71 | | template <typename T> |
72 | | inline void Vec3<T>::operator= (const Vec3 & rhs) |
73 | 0 | { |
74 | 0 | this->m_data[0] = rhs.m_data[0]; |
75 | 0 | this->m_data[1] = rhs.m_data[1]; |
76 | 0 | this->m_data[2] = rhs.m_data[2]; |
77 | 0 | } |
78 | | template <typename T> |
79 | | inline void Vec3<T>::operator+=(const Vec3 & rhs) |
80 | 0 | { |
81 | 0 | this->m_data[0] += rhs.m_data[0]; |
82 | 0 | this->m_data[1] += rhs.m_data[1]; |
83 | 0 | this->m_data[2] += rhs.m_data[2]; |
84 | 0 | } |
85 | | template <typename T> |
86 | | inline void Vec3<T>::operator-=(const Vec3 & rhs) |
87 | | { |
88 | | this->m_data[0] -= rhs.m_data[0]; |
89 | | this->m_data[1] -= rhs.m_data[1]; |
90 | | this->m_data[2] -= rhs.m_data[2]; |
91 | | } |
92 | | template <typename T> |
93 | | inline void Vec3<T>::operator-=(T a) |
94 | | { |
95 | | this->m_data[0] -= a; |
96 | | this->m_data[1] -= a; |
97 | | this->m_data[2] -= a; |
98 | | } |
99 | | template <typename T> |
100 | | inline void Vec3<T>::operator+=(T a) |
101 | | { |
102 | | this->m_data[0] += a; |
103 | | this->m_data[1] += a; |
104 | | this->m_data[2] += a; |
105 | | } |
106 | | template <typename T> |
107 | | inline void Vec3<T>::operator/=(T a) |
108 | | { |
109 | | this->m_data[0] /= a; |
110 | | this->m_data[1] /= a; |
111 | | this->m_data[2] /= a; |
112 | | } |
113 | | template <typename T> |
114 | | inline void Vec3<T>::operator*=(T a) |
115 | | { |
116 | | this->m_data[0] *= a; |
117 | | this->m_data[1] *= a; |
118 | | this->m_data[2] *= a; |
119 | | } |
120 | | template <typename T> |
121 | | inline Vec3<T> Vec3<T>::operator^ (const Vec3<T> & rhs) const |
122 | 0 | { |
123 | 0 | return Vec3<T>(m_data[1] * rhs.m_data[2] - m_data[2] * rhs.m_data[1], |
124 | 0 | m_data[2] * rhs.m_data[0] - m_data[0] * rhs.m_data[2], |
125 | 0 | m_data[0] * rhs.m_data[1] - m_data[1] * rhs.m_data[0]); |
126 | 0 | } |
127 | | template <typename T> |
128 | | inline T Vec3<T>::operator*(const Vec3<T> & rhs) const |
129 | | { |
130 | | return (m_data[0] * rhs.m_data[0] + m_data[1] * rhs.m_data[1] + m_data[2] * rhs.m_data[2]); |
131 | | } |
132 | | template <typename T> |
133 | | inline Vec3<T> Vec3<T>::operator+(const Vec3<T> & rhs) const |
134 | | { |
135 | | return Vec3<T>(m_data[0] + rhs.m_data[0],m_data[1] + rhs.m_data[1],m_data[2] + rhs.m_data[2]); |
136 | | } |
137 | | template <typename T> |
138 | | inline Vec3<T> Vec3<T>::operator-(const Vec3<T> & rhs) const |
139 | 0 | { |
140 | 0 | return Vec3<T>(m_data[0] - rhs.m_data[0],m_data[1] - rhs.m_data[1],m_data[2] - rhs.m_data[2]); |
141 | 0 | } |
142 | | template <typename T> |
143 | | inline Vec3<T> Vec3<T>::operator-() const |
144 | | { |
145 | | return Vec3<T>(-m_data[0],-m_data[1],-m_data[2]); |
146 | | } |
147 | | |
148 | | template <typename T> |
149 | | inline Vec3<T> Vec3<T>::operator*(T rhs) const |
150 | | { |
151 | | return Vec3<T>(rhs * this->m_data[0], rhs * this->m_data[1], rhs * this->m_data[2]); |
152 | | } |
153 | | template <typename T> |
154 | | inline Vec3<T> Vec3<T>::operator/ (T rhs) const |
155 | | { |
156 | | return Vec3<T>(m_data[0] / rhs, m_data[1] / rhs, m_data[2] / rhs); |
157 | | } |
158 | | template <typename T> |
159 | | inline Vec3<T>::Vec3(T a) |
160 | | { |
161 | | m_data[0] = m_data[1] = m_data[2] = a; |
162 | | } |
163 | | template <typename T> |
164 | | inline Vec3<T>::Vec3(T x, T y, T z) |
165 | 0 | { |
166 | 0 | m_data[0] = x; |
167 | 0 | m_data[1] = y; |
168 | 0 | m_data[2] = z; |
169 | 0 | } |
170 | | template <typename T> |
171 | | inline Vec3<T>::Vec3(const Vec3 & rhs) |
172 | | { |
173 | | m_data[0] = rhs.m_data[0]; |
174 | | m_data[1] = rhs.m_data[1]; |
175 | | m_data[2] = rhs.m_data[2]; |
176 | | } |
177 | | template <typename T> |
178 | 0 | inline Vec3<T>::~Vec3(void){}Unexecuted instantiation: o3dgc::Vec3<long>::~Vec3() Unexecuted instantiation: o3dgc::Vec3<float>::~Vec3() |
179 | | |
180 | | template <typename T> |
181 | 0 | inline Vec3<T>::Vec3() {}Unexecuted instantiation: o3dgc::Vec3<long>::Vec3() Unexecuted instantiation: o3dgc::Vec3<float>::Vec3() |
182 | | |
183 | | template <typename T> |
184 | | inline Vec2<T> operator*(T lhs, const Vec2<T> & rhs) |
185 | | { |
186 | | return Vec2<T>(lhs * rhs.X(), lhs * rhs.Y()); |
187 | | } |
188 | | template <typename T> |
189 | | inline T & Vec2<T>::X() |
190 | | { |
191 | | return m_data[0]; |
192 | | } |
193 | | template <typename T> |
194 | | inline T & Vec2<T>::Y() |
195 | | { |
196 | | return m_data[1]; |
197 | | } |
198 | | template <typename T> |
199 | | inline const T & Vec2<T>::X() const |
200 | | { |
201 | | return m_data[0]; |
202 | | } |
203 | | template <typename T> |
204 | | inline const T & Vec2<T>::Y() const |
205 | | { |
206 | | return m_data[1]; |
207 | | } |
208 | | template <typename T> |
209 | | inline double Vec2<T>::GetNorm() const |
210 | | { |
211 | | double a = (double) (m_data[0]); |
212 | | double b = (double) (m_data[1]); |
213 | | return sqrt(a*a+b*b); |
214 | | } |
215 | | template <typename T> |
216 | | inline void Vec2<T>::operator= (const Vec2 & rhs) |
217 | | { |
218 | | this->m_data[0] = rhs.m_data[0]; |
219 | | this->m_data[1] = rhs.m_data[1]; |
220 | | } |
221 | | template <typename T> |
222 | | inline void Vec2<T>::operator+=(const Vec2 & rhs) |
223 | | { |
224 | | this->m_data[0] += rhs.m_data[0]; |
225 | | this->m_data[1] += rhs.m_data[1]; |
226 | | } |
227 | | template <typename T> |
228 | | inline void Vec2<T>::operator-=(const Vec2 & rhs) |
229 | | { |
230 | | this->m_data[0] -= rhs.m_data[0]; |
231 | | this->m_data[1] -= rhs.m_data[1]; |
232 | | } |
233 | | template <typename T> |
234 | | inline void Vec2<T>::operator-=(T a) |
235 | | { |
236 | | this->m_data[0] -= a; |
237 | | this->m_data[1] -= a; |
238 | | } |
239 | | template <typename T> |
240 | | inline void Vec2<T>::operator+=(T a) |
241 | | { |
242 | | this->m_data[0] += a; |
243 | | this->m_data[1] += a; |
244 | | } |
245 | | template <typename T> |
246 | | inline void Vec2<T>::operator/=(T a) |
247 | | { |
248 | | this->m_data[0] /= a; |
249 | | this->m_data[1] /= a; |
250 | | } |
251 | | template <typename T> |
252 | | inline void Vec2<T>::operator*=(T a) |
253 | | { |
254 | | this->m_data[0] *= a; |
255 | | this->m_data[1] *= a; |
256 | | } |
257 | | template <typename T> |
258 | | inline T Vec2<T>::operator^ (const Vec2<T> & rhs) const |
259 | | { |
260 | | return m_data[0] * rhs.m_data[1] - m_data[1] * rhs.m_data[0]; |
261 | | } |
262 | | template <typename T> |
263 | | inline T Vec2<T>::operator*(const Vec2<T> & rhs) const |
264 | | { |
265 | | return (m_data[0] * rhs.m_data[0] + m_data[1] * rhs.m_data[1]); |
266 | | } |
267 | | template <typename T> |
268 | | inline Vec2<T> Vec2<T>::operator+(const Vec2<T> & rhs) const |
269 | | { |
270 | | return Vec2<T>(m_data[0] + rhs.m_data[0],m_data[1] + rhs.m_data[1]); |
271 | | } |
272 | | template <typename T> |
273 | | inline Vec2<T> Vec2<T>::operator-(const Vec2<T> & rhs) const |
274 | | { |
275 | | return Vec2<T>(m_data[0] - rhs.m_data[0],m_data[1] - rhs.m_data[1]); |
276 | | } |
277 | | template <typename T> |
278 | | inline Vec2<T> Vec2<T>::operator-() const |
279 | | { |
280 | | return Vec2<T>(-m_data[0],-m_data[1]) ; |
281 | | } |
282 | | |
283 | | template <typename T> |
284 | | inline Vec2<T> Vec2<T>::operator*(T rhs) const |
285 | | { |
286 | | return Vec2<T>(rhs * this->m_data[0], rhs * this->m_data[1]); |
287 | | } |
288 | | template <typename T> |
289 | | inline Vec2<T> Vec2<T>::operator/ (T rhs) const |
290 | | { |
291 | | return Vec2<T>(m_data[0] / rhs, m_data[1] / rhs); |
292 | | } |
293 | | template <typename T> |
294 | | inline Vec2<T>::Vec2(T a) |
295 | | { |
296 | | m_data[0] = m_data[1] = a; |
297 | | } |
298 | | template <typename T> |
299 | | inline Vec2<T>::Vec2(T x, T y) |
300 | | { |
301 | | m_data[0] = x; |
302 | | m_data[1] = y; |
303 | | } |
304 | | template <typename T> |
305 | | inline Vec2<T>::Vec2(const Vec2 & rhs) |
306 | | { |
307 | | m_data[0] = rhs.m_data[0]; |
308 | | m_data[1] = rhs.m_data[1]; |
309 | | } |
310 | | template <typename T> |
311 | | inline Vec2<T>::~Vec2(void){} |
312 | | |
313 | | template <typename T> |
314 | | inline Vec2<T>::Vec2() {} |
315 | | } |
316 | | #endif //O3DGC_VECTOR_INL |
317 | | |