My Project: dynamics.mod/NewtonDynamics/source/core/dgVector.h Source File

My Project

dgVector.h
Go to the documentation of this file.
1 /* Copyright (c) <2003-2011> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21
22 #ifndef __dgVector__
23 #define __dgVector__
24
25 #include "dgStdafx.h"
26 #include "dgTypes.h"
27 #include "dgDebug.h"
28 #include "dgMemory.h"
29
30
31
32 #define dgCheckVector(x) (dgCheckFloat(x[0]) && dgCheckFloat(x[1]) && dgCheckFloat(x[2]) && dgCheckFloat(x[3]))
33
34
35 template<class T>
36 class dgTemplateVector
37 {
38 public:
39 DG_INLINE dgTemplateVector ()
40 {
41 }
42
43 DG_INLINE dgTemplateVector (const T* const ptr)
44 :m_x(ptr[0]), m_y(ptr[1]), m_z(ptr[2]), m_w (T(0.0f))
45 {
46 // dgAssert (dgCheckVector ((*this)));
47 }
48
49 DG_INLINE dgTemplateVector (const dgTemplateVector<T>& copy)
50 :m_x(copy.m_x), m_y(copy.m_y), m_z(copy.m_z), m_w (copy.m_w)
51 {
52 // dgAssert (dgCheckVector ((*this)));
53 }
54
55 DG_INLINE dgTemplateVector (T x, T y, T z, T w)
56 :m_x(x), m_y(y), m_z(z), m_w (w)
57 {
58 }
59
60 DG_INLINE T& operator[] (dgInt32 i)
61 {
62 dgAssert (i < 4);
63 dgAssert (i >= 0);
64 return (&m_x)[i];
65 }
66
67 DG_INLINE const T& operator[] (dgInt32 i) const
68 {
69 dgAssert (i < 4);
70 dgAssert (i >= 0);
71 return (&m_x)[i];
72 }
73
74 DG_INLINE dgTemplateVector<T> Scale3 (T scale) const
75 {
76 return dgTemplateVector<T> (m_x * scale, m_y * scale, m_z * scale, m_w);
77 }
78
79 DG_INLINE dgTemplateVector<T> Scale4 (T scale) const
80 {
81 return dgTemplateVector<T> (m_x * scale, m_y * scale, m_z * scale, m_w * scale);
82 }
83
84 DG_INLINE dgTemplateVector<T> operator+ (const dgTemplateVector<T>& B) const
85 {
86 return dgTemplateVector<T> (m_x + B.m_x, m_y + B.m_y, m_z + B.m_z, m_w + B.m_w);
87 }
88
89 DG_INLINE dgTemplateVector<T>& operator+= (const dgTemplateVector<T>& A)
90 {
91 return (*this = dgTemplateVector<T> (m_x + A.m_x, m_y + A.m_y, m_z + A.m_z, m_w + A.m_w));
92 }
93
94 DG_INLINE dgTemplateVector<T> operator- (const dgTemplateVector<T>& A) const
95 {
96 return dgTemplateVector<T> (m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w - A.m_w);
97 }
98
99 DG_INLINE dgTemplateVector<T>& operator-= (const dgTemplateVector<T>& A)
100 {
101 return (*this = dgTemplateVector<T> (m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w - A.m_w));
102 }
103
104 // return dot product
105 DG_INLINE T operator% (const dgTemplateVector<T>& A) const
106 {
107 return m_x * A.m_x + m_y * A.m_y + m_z * A.m_z;
108 }
109
110 // return cross product
111 DG_INLINE dgTemplateVector<T> operator* (const dgTemplateVector<T>& B) const
112 {
113 return dgTemplateVector<T> (m_y * B.m_z - m_z * B.m_y,
114 m_z * B.m_x - m_x * B.m_z,
115 m_x * B.m_y - m_y * B.m_x, m_w);
116 }
117
118 DG_INLINE dgTemplateVector<T> AddHorizontal () const
119 {
120 T val (m_x + m_y + m_z + m_w);
121 return dgTemplateVector<T> (val, val, val, val);
122 }
123
124 // return dot 4d dot product
125 DG_INLINE dgTemplateVector<T> DotProduct4 (const dgTemplateVector &A) const
126 {
127 T val (m_x * A.m_x + m_y * A.m_y + m_z * A.m_z + m_w * A.m_w);
128 return dgTemplateVector<T> (val, val, val, val);
129 }
130
131
132 DG_INLINE dgTemplateVector<T> CrossProduct4 (const dgTemplateVector &A, const dgTemplateVector &B) const
133 {
134 T cofactor[3][3];
135 T array[4][4];
136
137 const dgTemplateVector<T>& me = *this;
138 for (dgInt32 i = 0; i < 4; i ++) {
139 array[0][i] = me[i];
140 array[1][i] = A[i];
141 array[2][i] = B[i];
142 array[3][i] = T (1.0f);
143 }
144
145 dgTemplateVector<T> normal;
146 T sign = T (-1.0f);
147 for (dgInt32 i = 0; i < 4; i ++) {
148
149 for (dgInt32 j = 0; j < 3; j ++) {
150 dgInt32 k0 = 0;
151 for (dgInt32 k = 0; k < 4; k ++) {
152 if (k != i) {
153 cofactor[j][k0] = array[j][k];
154 k0 ++;
155 }
156 }
157 }
158 T x = cofactor[0][0] * (cofactor[1][1] * cofactor[2][2] - cofactor[1][2] * cofactor[2][1]);
159 T y = cofactor[0][1] * (cofactor[1][2] * cofactor[2][0] - cofactor[1][0] * cofactor[2][2]);
160 T z = cofactor[0][2] * (cofactor[1][0] * cofactor[2][1] - cofactor[1][1] * cofactor[2][0]);
161 T det = x + y + z;
162
163 normal[i] = sign * det;
164 sign *= T (-1.0f);
165 }
166
167 return normal;
168 }
169
170 // component wise multiplication
171 DG_INLINE dgTemplateVector<T> CompProduct3 (const dgTemplateVector<T>& A) const
172 {
173 return dgTemplateVector<T> (m_x * A.m_x, m_y * A.m_y, m_z * A.m_z, A.m_w);
174 }
175
176 // component wise 4d multiplication
177 DG_INLINE dgTemplateVector<T> CompProduct4 (const dgTemplateVector<T>& A) const
178 {
179 return dgTemplateVector<T> (m_x * A.m_x, m_y * A.m_y, m_z * A.m_z, m_w * A.m_w);
180 }
181
182
183 // check validity of floats
184 #ifdef _DEBUG
185 void Trace () const
186 {
187 dgTrace (("%f %f %f %f\n", m_x, m_y, m_z, m_w));
188 }
189 #endif
190
191 DG_CLASS_ALLOCATOR(allocator)
192
193 T m_x;
194 T m_y;
195 T m_z;
196 T m_w;
197 };
198
199 class dgVector;
200
201 // *****************************************************************************************
202 //
203 // 256 bit double precision vector class declaration
204 //
205 // *****************************************************************************************
206 DG_MSC_VECTOR_ALIGMENT
207 class dgBigVector: public dgTemplateVector<dgFloat64>
208 {
209 public:
210 DG_INLINE dgBigVector()
211 :dgTemplateVector<dgFloat64>()
212 {
213 }
214
215 DG_INLINE dgBigVector (const dgVector& v)
216 :dgTemplateVector<dgFloat64>(((dgTemplateVector<dgFloat32>&)v).m_x, ((dgTemplateVector<dgFloat32>&)v).m_y, ((dgTemplateVector<dgFloat32>&)v).m_z, ((dgTemplateVector<dgFloat32>&)v).m_w)
217 {
218 dgAssert (dgCheckVector ((*this)));
219 }
220
221 DG_INLINE dgBigVector (const dgTemplateVector<dgFloat64>& v)
222 :dgTemplateVector<dgFloat64>(v)
223 {
224 dgAssert (dgCheckVector ((*this)));
225 }
226
227 DG_INLINE dgBigVector (const dgBigVector& copy)
228 :dgTemplateVector<dgFloat64>(copy)
229 {
230 // dgAssert (dgCheckVector ((*this)));
231 }
232
233
234 DG_INLINE dgBigVector (const dgFloat32* const ptr)
235 :dgTemplateVector<dgFloat64>(ptr[0], ptr[1], ptr[2], dgFloat64 (0.0f))
236 {
237 dgAssert (dgCheckVector ((*this)));
238 }
239
240 #ifndef _NEWTON_USE_DOUBLE
241 DG_INLINE dgBigVector (const dgFloat64* const ptr)
242 :dgTemplateVector<dgFloat64>(ptr)
243 {
244 dgAssert (dgCheckVector ((*this)));
245 }
246 #endif
247
248 DG_INLINE dgBigVector (dgFloat64 x, dgFloat64 y, dgFloat64 z, dgFloat64 w)
249 :dgTemplateVector<dgFloat64>(x, y, z, w)
250 {
251 dgAssert (dgCheckVector ((*this)));
252 }
253
254 } DG_GCC_VECTOR_ALIGMENT;
255
256
257
258 // *****************************************************************************************
259 //
260 // 128 bit single precision vector class declaration
261 //
262 // *****************************************************************************************
263 #ifdef DG_SCALAR_VECTOR_CLASS
264
265 DG_MSC_VECTOR_ALIGMENT
266 class dgVector
267 {
268 public:
269 DG_INLINE dgVector()
270 {
271 }
272
273 DG_INLINE dgVector(dgFloat32 val)
274 :m_x(val), m_y(val), m_z(val), m_w(val)
275 {
276 }
277
278 DG_INLINE dgVector (const dgVector& v)
279 :m_x(v.m_x), m_y(v.m_y), m_z(v.m_z), m_w(v.m_w)
280 {
281 //dgAssert (dgCheckVector ((*this)));
282 }
283
284 DG_INLINE dgVector (const dgFloat32* const ptr)
285 :m_x(ptr[0]), m_y(ptr[1]), m_z(ptr[2]), m_w (dgFloat32 (0.0f))
286 {
287 dgAssert (dgCheckVector ((*this)));
288 }
289
290 DG_INLINE dgVector (dgFloat32 x, dgFloat32 y, dgFloat32 z, dgFloat32 w)
291 :m_x(x), m_y(y), m_z(z), m_w(w)
292 {
293 dgAssert (dgCheckVector ((*this)));
294 }
295
296 DG_INLINE dgVector (dgInt32 ix, dgInt32 iy, dgInt32 iz, dgInt32 iw)
297 :m_x(*((dgFloat32*)&ix)), m_y(*((dgFloat32*)&iy)), m_z(*((dgFloat32*)&iz)), m_w(*((dgFloat32*)&iw))
298 {
299 }
300
301 DG_INLINE dgVector (const dgBigVector& copy)
302 :m_x(dgFloat32 (copy.m_x)), m_y(dgFloat32 (copy.m_y)), m_z(dgFloat32 (copy.m_z)), m_w(dgFloat32 (copy.m_w))
303 {
304 dgAssert (dgCheckVector ((*this)));
305 }
306
307 DG_INLINE dgFloat32 GetScalar () const
308 {
309 return m_x;
310 }
311
312 DG_INLINE void Store (dgFloat32* const dst) const
313 {
314 dst[0] = m_x;
315 dst[1] = m_y;
316 dst[2] = m_z;
317 dst[3] = m_w;
318 }
319
320 DG_INLINE dgVector BroadcastX () const
321 {
322 return dgVector (m_x);
323 }
324
325 DG_INLINE dgVector BroadcastY () const
326 {
327 return dgVector (m_y);
328 }
329
330 DG_INLINE dgVector BroadcastZ () const
331 {
332 return dgVector (m_z);
333 }
334
335 DG_INLINE dgVector BroadcastW () const
336 {
337 return dgVector (m_w);
338 }
339
340
341 DG_INLINE dgFloat32& operator[] (dgInt32 i)
342 {
343 dgAssert (i < 4);
344 dgAssert (i >= 0);
345 return (&m_x)[i];
346 }
347
348 DG_INLINE const dgFloat32& operator[] (dgInt32 i) const
349 {
350 dgAssert (i < 4);
351 dgAssert (i >= 0);
352 return (&m_x)[i];
353 }
354
355 DG_INLINE dgVector operator+ (const dgVector& A) const
356 {
357 return dgVector (m_x + A.m_x, m_y + A.m_y, m_z + A.m_z, m_w + A.m_w);
358 }
359
360 DG_INLINE dgVector operator- (const dgVector& A) const
361 {
362 return dgVector (m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w - A.m_w);
363 }
364
365 DG_INLINE dgVector &operator+= (const dgVector& A)
366 {
367 return (*this = dgVector (m_x + A.m_x, m_y + A.m_y, m_z + A.m_z, m_w + A.m_w));
368 }
369
370 DG_INLINE dgVector &operator-= (const dgVector& A)
371 {
372 return (*this = dgVector (m_x - A.m_x, m_y - A.m_y, m_z - A.m_z, m_w - A.m_w));
373 }
374
375 DG_INLINE dgVector AddHorizontal () const
376 {
377 return dgVector (m_x + m_y + m_z + m_w);
378 }
379
380
381 DG_INLINE dgVector Scale3 (dgFloat32 scale) const
382 {
383 return dgVector (m_x * scale, m_y * scale, m_z * scale, m_w);
384 }
385
386 DG_INLINE dgVector Scale4 (dgFloat32 scale) const
387 {
388 return dgVector (m_x * scale, m_y * scale, m_z * scale, m_w * scale);
389 }
390
391
392 // component wise multiplication
393 DG_INLINE dgVector CompProduct3 (const dgVector& A) const
394 {
395 return dgVector (m_x * A.m_x, m_y * A.m_y, m_z * A.m_z, A.m_w);
396 }
397
398 // component wise 4d multiplication
399 DG_INLINE dgVector CompProduct4 (const dgVector& A) const
400 {
401 return dgVector (m_x * A.m_x, m_y * A.m_y, m_z * A.m_z, m_w * A.m_w);
402 }
403
404
405 // return dot product
406 DG_INLINE dgFloat32 operator% (const dgVector& A) const
407 {
408 return m_x * A.m_x + m_y * A.m_y + m_z * A.m_z;
409 }
410
411 // return cross product
412 DG_INLINE dgVector operator* (const dgVector& B) const
413 {
414 return dgVector (m_y * B.m_z - m_z * B.m_y,
415 m_z * B.m_x - m_x * B.m_z,
416 m_x * B.m_y - m_y * B.m_x, m_w);
417 }
418
419
420 DG_INLINE dgVector GetInt () const
421 {
422 return dgVector (dgInt32 (dgFloor (m_x)), dgInt32(dgFloor (m_y)), dgInt32(dgFloor (m_z)), dgInt32 (dgFloor (m_w)));
423 }
424
425 DG_INLINE dgVector TestZero() const
426 {
427 const dgInt32* const a = (dgInt32*)&m_x;
428 return dgVector ((a[0] == 0) ? dgInt32 (0xffffffff) : dgInt32 (0),
429 (a[1] == 0) ? dgInt32 (0xffffffff) : dgInt32 (0),
430 (a[2] == 0) ? dgInt32 (0xffffffff) : dgInt32 (0),
431 (a[3] == 0) ? dgInt32 (0xffffffff) : dgInt32 (0));
432 }
433
434
435 DG_INLINE dgVector Floor () const
436 {
437 return dgVector (dgFloor (m_x), dgFloor (m_y), dgFloor (m_z), dgFloor (m_w));
438 }
439
440 DG_INLINE dgVector DotProduct4 (const dgVector &A) const
441 {
442 return dgVector (m_x * A.m_x + m_y * A.m_y + m_z * A.m_z + m_w * A.m_w);
443 }
444
445 DG_INLINE dgVector InvMagSqrt () const
446 {
447 return dgVector (dgRsqrt (DotProduct4(*this).m_x));
448 }
449
450 DG_INLINE dgVector Reciproc () const
451 {
452 return dgVector (dgFloat32 (1.0f) / m_x, dgFloat32 (1.0f) / m_y, dgFloat32 (1.0f) / m_z, dgFloat32 (1.0f) / m_w);
453 }
454
455 DG_INLINE dgVector Sqrt () const
456 {
457 return dgVector (dgSqrt (m_x), dgSqrt (m_y), dgSqrt (m_z), dgSqrt (m_w));
458 }
459
460 DG_INLINE dgVector InvSqrt () const
461 {
462 return dgVector (dgRsqrt (m_x), dgRsqrt (m_y), dgRsqrt (m_z), dgRsqrt (m_w));
463 }
464
465 dgVector Abs () const
466 {
467 return dgVector ((m_x > dgFloat32 (0.0f)) ? m_x : -m_x,
468 (m_y > dgFloat32 (0.0f)) ? m_y : -m_y,
469 (m_z > dgFloat32 (0.0f)) ? m_z : -m_z,
470 (m_w > dgFloat32 (0.0f)) ? m_w : -m_w);
471 }
472
473 dgVector GetMax (const dgVector& data) const
474 {
475 return dgVector ((m_x > data.m_x) ? m_x : data.m_x,
476 (m_y > data.m_y) ? m_y : data.m_y,
477 (m_z > data.m_z) ? m_z : data.m_z,
478 (m_w > data.m_w) ? m_w : data.m_w);
479 }
480
481 dgVector GetMin (const dgVector& data) const
482 {
483 return dgVector ((m_x < data.m_x) ? m_x : data.m_x,
484 (m_y < data.m_y) ? m_y : data.m_y,
485 (m_z < data.m_z) ? m_z : data.m_z,
486 (m_w < data.m_w) ? m_w : data.m_w);
487 }
488
489
490 // relational operators
491 DG_INLINE dgVector operator== (const dgVector& data) const
492 {
493 return dgVector ((m_x == data.m_x) ? dgInt32 (0xffffffff) : 0,
494 (m_y == data.m_y) ? dgInt32 (0xffffffff) : 0,
495 (m_z == data.m_z) ? dgInt32 (0xffffffff) : 0,
496 (m_w == data.m_w) ? dgInt32 (0xffffffff) : 0);
497 }
498
499 DG_INLINE dgVector operator> (const dgVector& data) const
500 {
501 return dgVector ((m_x > data.m_x) ? dgInt32 (0xffffffff) : 0,
502 (m_y > data.m_y) ? dgInt32 (0xffffffff) : 0,
503 (m_z > data.m_z) ? dgInt32 (0xffffffff) : 0,
504 (m_w > data.m_w) ? dgInt32 (0xffffffff) : 0);
505 }
506
507 DG_INLINE dgVector operator< (const dgVector& data) const
508 {
509 return dgVector ((m_x < data.m_x) ? dgInt32 (0xffffffff) : 0,
510 (m_y < data.m_y) ? dgInt32 (0xffffffff) : 0,
511 (m_z < data.m_z) ? dgInt32 (0xffffffff) : 0,
512 (m_w < data.m_w) ? dgInt32 (0xffffffff) : 0);
513 }
514
515 DG_INLINE dgVector operator>= (const dgVector& data) const
516 {
517 return dgVector ((m_x >= data.m_x) ? dgInt32 (0xffffffff) : 0,
518 (m_y >= data.m_y) ? dgInt32 (0xffffffff) : 0,
519 (m_z >= data.m_z) ? dgInt32 (0xffffffff) : 0,
520 (m_w >= data.m_w) ? dgInt32 (0xffffffff) : 0);
521 }
522
523 DG_INLINE dgVector operator<= (const dgVector& data) const
524 {
525 return dgVector ((m_x <= data.m_x) ? dgInt32 (0xffffffff) : 0,
526 (m_y <= data.m_y) ? dgInt32 (0xffffffff) : 0,
527 (m_z <= data.m_z) ? dgInt32 (0xffffffff) : 0,
528 (m_w <= data.m_w) ? dgInt32 (0xffffffff) : 0);
529 }
530
531
532 // logical operations
533 DG_INLINE dgVector operator& (const dgVector& data) const
534 {
535 const dgInt32* const a = (dgInt32*)&m_x;
536 const dgInt32* const b = (dgInt32*)&data.m_x;
537 return dgVector (a[0] & b[0], a[1] & b[1], a[2] & b[2], a[3] & b[3]);
538 }
539
540 DG_INLINE dgVector operator| (const dgVector& data) const
541 {
542 const dgInt32* const a = (dgInt32*)&m_x;
543 const dgInt32* const b = (dgInt32*)&data.m_x;
544 return dgVector (a[0] | b[0], a[1] | b[1], a[2] | b[2], a[3] | b[3]);
545 }
546
547 DG_INLINE dgVector operator^ (const dgVector& data) const
548 {
549 const dgInt32* const a = (dgInt32*)&m_x;
550 const dgInt32* const b = (dgInt32*)&data.m_x;
551 return dgVector (a[0] ^ b[0], a[1] ^ b[1], a[2] ^ b[2], a[3] ^ b[3]);
552 }
553
554 DG_INLINE dgVector AndNot (const dgVector& data) const
555 {
556 const dgInt32* const a = (dgInt32*)&m_x;
557 const dgInt32* const b = (dgInt32*)&data.m_x;
558 return dgVector (a[0] & ~b[0], a[1] & ~b[1], a[2] & ~b[2], a[3] & ~b[3]);
559 }
560
561 DG_INLINE dgInt32 GetSignMask() const
562 {
563 const dgInt32* const a = (dgInt32*)&m_x;
564 return (((a[0] & 0x80000000) ? 1 : 0) | ((a[1] & 0x80000000) ? 2 : 0) | ((a[2] & 0x80000000) ? 4 : 0) | ((a[3] & 0x80000000) ? 8 : 0));
565 }
566
567 DG_INLINE dgVector ShiftTripleRight () const
568 {
569 return dgVector (m_z, m_x, m_y, m_w);
570 }
571
572
573 DG_INLINE dgVector MoveLow (const dgVector& data) const
574 {
575 return dgVector (m_x, m_y, data.m_x, data.m_y);
576 }
577
578 DG_INLINE dgVector MoveHigh (const dgVector& data) const
579 {
580 return dgVector (data.m_z, data.m_w, m_z, m_w);
581 }
582
583 DG_INLINE dgVector PackLow (const dgVector& data) const
584 {
585 return dgVector (m_x, data.m_x, m_y, data.m_y);
586 }
587
588 DG_INLINE dgVector PackHigh (const dgVector& data) const
589 {
590 return dgVector (m_z, data.m_z, m_w, data.m_w);
591 }
592
593 DG_INLINE static void Transpose4x4 (dgVector& dst0, dgVector& dst1, dgVector& dst2, dgVector& dst3,
594 const dgVector& src0, const dgVector& src1, const dgVector& src2, const dgVector& src3)
595 {
596 dgVector tmp0 (src0.PackLow(src1));
597 dgVector tmp1 (src2.PackLow(src3));
598 dgVector tmp2 (src0.PackHigh(src1));
599 dgVector tmp3 (src2.PackHigh(src3));
600
601 dst0 = tmp0.MoveLow (tmp1);
602 dst1 = tmp1.MoveHigh (tmp0);
603 dst2 = tmp2.MoveLow (tmp3);
604 dst3 = tmp3.MoveHigh (tmp2);
605 }
606
607 DG_CLASS_ALLOCATOR(allocator)
608
609 union {
610 struct {
611 dgFloat32 m_x;
612 dgFloat32 m_y;
613 dgFloat32 m_z;
614 dgFloat32 m_w;
615 };
616 struct {
617 dgInt32 m_ix;
618 dgInt32 m_iy;
619 dgInt32 m_iz;
620 dgInt32 m_iw;
621 };
622 };
623
624
625 static dgVector m_one;
626 static dgVector m_wOne;
627 static dgVector m_half;
628 static dgVector m_two;
629 static dgVector m_three;
630 static dgVector m_negOne;
631 static dgVector m_signMask;
632 static dgVector m_triplexMask;
633 }DG_GCC_VECTOR_ALIGMENT;
634
635
636 #else
637
638 DG_MSC_VECTOR_ALIGMENT
639 class dgVector
640 {
641 #define PURMUT_MASK(w, z, y, x) _MM_SHUFFLE (w, z, y, x)
642
643 public:
644 DG_INLINE dgVector()
645 {
646 }
647
648 DG_INLINE dgVector(const __m128 type)
649 :m_type (type)
650 {
651 }
652
653 DG_INLINE dgVector(const __m128i type)
654 :m_typeInt (type)
655 {
656 }
657
658 DG_INLINE dgVector (const dgFloat32 a)
659 : m_type(_mm_set_ps1(a))
660 {
661 }
662
663 DG_INLINE dgVector (const dgFloat32* const ptr)
664 :m_type(_mm_loadu_ps (ptr))
665 {
666 m_type = _mm_and_ps (m_type, m_triplexMask.m_type);
667 }
668
669 DG_INLINE dgVector (const dgVector& copy)
670 :m_type(copy.m_type)
671 {
672 }
673
674
675 DG_INLINE dgVector (const dgBigVector& copy)
676 :m_type(_mm_set_ps(dgFloat32 (copy.m_w), dgFloat32 (copy.m_z), dgFloat32 (copy.m_y), dgFloat32 (copy.m_x)))
677 {
678 }
679
680 DG_INLINE dgVector (dgFloat32 x, dgFloat32 y, dgFloat32 z, dgFloat32 w)
681 :m_type(_mm_set_ps(w, z, y, x))
682 {
683 }
684
685 DG_INLINE dgVector (dgInt32 ix, dgInt32 iy, dgInt32 iz, dgInt32 iw)
686 :m_type(_mm_set_ps(*(dgFloat32*)&iw, *(dgFloat32*)&iz, *(dgFloat32*)&iy, *(dgFloat32*)&ix))
687 {
688 }
689
690
691 DG_INLINE dgFloat32 GetScalar () const
692 {
693 dgFloat32 scalar;
694 _mm_store_ss(&scalar, m_type);
695 return scalar;
696 }
697
698 DG_INLINE void Store (dgFloat32* const dst) const
699 {
700 _mm_storeu_ps(dst, m_type);
701 }
702
703 DG_INLINE dgVector BroadcastX () const
704 {
705 return _mm_shuffle_ps (m_type, m_type, PURMUT_MASK(0, 0, 0, 0));
706 }
707
708 DG_INLINE dgVector BroadcastY () const
709 {
710 return _mm_shuffle_ps (m_type, m_type, PURMUT_MASK(1, 1, 1, 1));
711 }
712
713 DG_INLINE dgVector BroadcastZ () const
714 {
715 return _mm_shuffle_ps (m_type, m_type, PURMUT_MASK(2, 2, 2, 2));
716 }
717
718 DG_INLINE dgVector BroadcastW () const
719 {
720 return _mm_shuffle_ps (m_type, m_type, PURMUT_MASK(3, 3, 3, 3));
721 }
722
723
724 DG_INLINE dgVector Scale3 (dgFloat32 s) const
725 {
726 dgVector tmp (s, s, s, dgFloat32 (1.0f));
727 return _mm_mul_ps (m_type, tmp.m_type);
728 }
729
730 DG_INLINE dgVector Scale4 (dgFloat32 s) const
731 {
732 return _mm_mul_ps (m_type, _mm_set_ps1(s));
733 }
734
735
736 DG_INLINE dgFloat32& operator[] (dgInt32 i)
737 {
738 dgAssert (i < 4);
739 dgAssert (i >= 0);
740 return m_f[i];
741 }
742
743 DG_INLINE const dgFloat32& operator[] (dgInt32 i) const
744 {
745 dgAssert (i < 4);
746 dgAssert (i >= 0);
747 return m_f[i];
748 }
749
750 DG_INLINE dgVector operator+ (const dgVector& A) const
751 {
752 return _mm_add_ps (m_type, A.m_type);
753 }
754
755
756 DG_INLINE dgVector operator- (const dgVector& A) const
757 {
758 return _mm_sub_ps (m_type, A.m_type);
759 }
760
761 DG_INLINE dgVector &operator+= (const dgVector& A)
762 {
763 return (*this = _mm_add_ps (m_type, A.m_type));
764 }
765
766 DG_INLINE dgVector &operator-= (const dgVector& A)
767 {
768 return (*this = _mm_sub_ps (m_type, A.m_type));
769 }
770
771 // return dot product
772 DG_INLINE dgFloat32 operator% (const dgVector& A) const
773 {
774 #ifdef DG_SSE4_INSTRUCTIONS_SET
775 return dgVector (_mm_dp_ps (m_type, A.m_type, 0x77)).m_x;
776 #else
777 dgVector tmp (A & m_triplexMask);
778 dgAssert ((m_w * tmp.m_w) == dgFloat32 (0.0f));
779 return CompProduct4(tmp).AddHorizontal().m_x;
780 #endif
781 }
782
783 DG_INLINE dgVector DotProduct4 (const dgVector& A) const
784 {
785 #ifdef DG_SSE4_INSTRUCTIONS_SET
786 return _mm_dp_ps (m_type, A.m_type, 0xff);
787 #else
788 return CompProduct4(A).AddHorizontal();
789 #endif
790 }
791
792 // return cross product
793 DG_INLINE dgVector operator* (const dgVector& B) const
794 {
795 return _mm_sub_ps (_mm_mul_ps (_mm_shuffle_ps (m_type, m_type, PURMUT_MASK(3, 0, 2, 1)), _mm_shuffle_ps (B.m_type, B.m_type, PURMUT_MASK(3, 1, 0, 2))),
796 _mm_mul_ps (_mm_shuffle_ps (m_type, m_type, PURMUT_MASK(3, 1, 0, 2)), _mm_shuffle_ps (B.m_type, B.m_type, PURMUT_MASK(3, 0, 2, 1))));
797
798 }
799
800 DG_INLINE dgVector CrossProduct4 (const dgVector& A, const dgVector& B) const
801 {
802 dgFloat32 cofactor[3][3];
803 dgFloat32 array[4][4];
804
805 const dgVector& me = *this;
806 for (dgInt32 i = 0; i < 4; i ++) {
807 array[0][i] = me[i];
808 array[1][i] = A[i];
809 array[2][i] = B[i];
810 array[3][i] = dgFloat32 (1.0f);
811 }
812
813 dgVector normal;
814 dgFloat32 sign = dgFloat32 (-1.0f);
815 for (dgInt32 i = 0; i < 4; i ++) {
816
817 for (dgInt32 j = 0; j < 3; j ++) {
818 dgInt32 k0 = 0;
819 for (dgInt32 k = 0; k < 4; k ++) {
820 if (k != i) {
821 cofactor[j][k0] = array[j][k];
822 k0 ++;
823 }
824 }
825 }
826 dgFloat32 x = cofactor[0][0] * (cofactor[1][1] * cofactor[2][2] - cofactor[1][2] * cofactor[2][1]);
827 dgFloat32 y = cofactor[0][1] * (cofactor[1][2] * cofactor[2][0] - cofactor[1][0] * cofactor[2][2]);
828 dgFloat32 z = cofactor[0][2] * (cofactor[1][0] * cofactor[2][1] - cofactor[1][1] * cofactor[2][0]);
829 dgFloat32 det = x + y + z;
830
831 normal[i] = sign * det;
832 sign *= dgFloat32 (-1.0f);
833 }
834
835 return normal;
836 }
837
838 // component wise multiplication
839 DG_INLINE dgVector CompProduct3 (const dgVector& A) const
840 {
841 dgVector tmp ((A & m_triplexMask) | m_wOne);
842 return _mm_mul_ps (m_type, tmp.m_type);
843 }
844
845 DG_INLINE dgVector Reciproc () const
846 {
847 return _mm_div_ps (m_one.m_type, m_type);
848 }
849
850 // component wise multiplication
851 DG_INLINE dgVector CompProduct4 (const dgVector& A) const
852 {
853 return _mm_mul_ps (m_type, A.m_type);
854 }
855
856 DG_INLINE dgVector AddHorizontal () const
857 {
858 dgVector tmp (_mm_hadd_ps (m_type, m_type));
859 return _mm_hadd_ps (tmp.m_type, tmp.m_type);
860 }
861
862 DG_INLINE dgVector Abs () const
863 {
864 // __m128i shitSign = _mm_srli_epi32 (_mm_slli_epi32 (*((__m128i*) &m_type), 1), 1);
865 // return *(__m128*)&shitSign;
866 return _mm_and_ps (m_type, m_signMask.m_type);
867 }
868
869 dgVector GetMax (const dgVector& data) const
870 {
871 return _mm_max_ps (m_type, data.m_type);
872 }
873
874 dgVector GetMin (const dgVector& data) const
875 {
876 return _mm_min_ps (m_type, data.m_type);
877 }
878
879 //DG_INLINE dgInt32 GetInt () const
880 DG_INLINE dgVector GetInt () const
881 {
882 //return _mm_cvtss_si32(m_type);
883 return dgVector(_mm_cvtps_epi32(Floor().m_type));
884 }
885
886 DG_INLINE dgVector TestZero() const
887 {
888 return _mm_cmpeq_epi32 (m_typeInt, dgVector (dgFloat32 (0.0f)).m_typeInt);
889 }
890
891 DG_INLINE dgVector Floor () const
892 {
893 // dgVector mask ((dgFloat32 (1.5f) * dgFloat32 (1<<23)));
894 // dgVector ret (_mm_sub_ps(_mm_add_ps(m_type, mask.m_type), mask.m_type));
895 // dgVector adjust (_mm_cmplt_ps (m_type, ret.m_type));
896 // ret = _mm_sub_ps (ret.m_type, _mm_and_ps(_mm_set_ps1(1.0), adjust.m_type));
897
898 dgVector truncated (_mm_cvtepi32_ps (_mm_cvttps_epi32 (m_type)));
899 dgVector ret (truncated - (dgVector::m_one & (*this < truncated)));
900 dgAssert (ret.m_f[0] == dgFloor(m_f[0]));
901 dgAssert (ret.m_f[1] == dgFloor(m_f[1]));
902 dgAssert (ret.m_f[2] == dgFloor(m_f[2]));
903 dgAssert (ret.m_f[3] == dgFloor(m_f[3]));
904 return ret;
905 }
906
907 DG_INLINE dgVector Sqrt () const
908 {
909 return dgVector (_mm_sqrt_ps(m_type));
910 }
911
912 DG_INLINE dgVector InvSqrt () const
913 {
914 dgVector tmp0 (_mm_rsqrt_ps(m_type));
915 return m_half.CompProduct4(tmp0).CompProduct4((m_three - CompProduct4(tmp0).CompProduct4(tmp0)));
916 }
917
918 DG_INLINE dgVector InvMagSqrt () const
919 {
920 return DotProduct4(*this).InvSqrt();
921 }
922
923
924 // relational operators
925 DG_INLINE dgVector operator> (const dgVector& data) const
926 {
927 return _mm_cmpgt_ps (m_type, data.m_type);
928 }
929
930 DG_INLINE dgVector operator== (const dgVector& data) const
931 {
932 return _mm_cmpeq_ps (m_type, data.m_type);
933 }
934
935 DG_INLINE dgVector operator< (const dgVector& data) const
936 {
937 return _mm_cmplt_ps (m_type, data.m_type);
938 }
939
940 DG_INLINE dgVector operator>= (const dgVector& data) const
941 {
942 return _mm_cmpge_ps (m_type, data.m_type);
943 }
944
945 DG_INLINE dgVector operator<= (const dgVector& data) const
946 {
947 return _mm_cmple_ps (m_type, data.m_type);
948 }
949
950 // logical operations
951 DG_INLINE dgVector operator& (const dgVector& data) const
952 {
953 return _mm_and_ps (m_type, data.m_type);
954 }
955
956 DG_INLINE dgVector operator| (const dgVector& data) const
957 {
958 return _mm_or_ps (m_type, data.m_type);
959 }
960
961 DG_INLINE dgVector operator^ (const dgVector& data) const
962 {
963 return _mm_xor_ps (m_type, data.m_type);
964 }
965
966 DG_INLINE dgVector AndNot (const dgVector& data) const
967 {
968 return _mm_andnot_ps (data.m_type, m_type);
969 }
970
971 DG_INLINE dgInt32 GetSignMask() const
972 {
973 return _mm_movemask_ps(m_type);
974 }
975
976 DG_INLINE dgVector ShiftTripleRight () const
977 {
978 return _mm_shuffle_ps(m_type, m_type, PURMUT_MASK(3, 1, 0, 2));
979 }
980
981
982 DG_INLINE dgVector MoveLow (const dgVector& data) const
983 {
984 return _mm_movelh_ps (m_type, data.m_type);
985 }
986
987 DG_INLINE dgVector MoveHigh (const dgVector& data) const
988 {
989 return _mm_movehl_ps (m_type, data.m_type);
990 }
991
992 DG_INLINE dgVector PackLow (const dgVector& data) const
993 {
994 return _mm_unpacklo_ps (m_type, data.m_type);
995 }
996
997 DG_INLINE dgVector PackHigh (const dgVector& data) const
998 {
999 return _mm_unpackhi_ps (m_type, data.m_type);
1000 }
1001
1002
1003 DG_INLINE static void Transpose4x4 (dgVector& dst0, dgVector& dst1, dgVector& dst2, dgVector& dst3,
1004 const dgVector& src0, const dgVector& src1, const dgVector& src2, const dgVector& src3)
1005 {
1006 dgVector tmp0 (src0.PackLow(src1));
1007 dgVector tmp1 (src2.PackLow(src3));
1008 dgVector tmp2 (src0.PackHigh(src1));
1009 dgVector tmp3 (src2.PackHigh(src3));
1010
1011 dst0 = tmp0.MoveLow (tmp1);
1012 dst1 = tmp1.MoveHigh (tmp0);
1013 dst2 = tmp2.MoveLow (tmp3);
1014 dst3 = tmp3.MoveHigh (tmp2);
1015 }
1016
1017
1018 DG_CLASS_ALLOCATOR(allocator)
1019
1020 union {
1021 __m128 m_type;
1022 __m128i m_typeInt;
1023 dgFloat32 m_f[4];
1024 struct {
1025 dgFloat32 m_x;
1026 dgFloat32 m_y;
1027 dgFloat32 m_z;
1028 dgFloat32 m_w;
1029 };
1030 struct {
1031 dgInt32 m_ix;
1032 dgInt32 m_iy;
1033 dgInt32 m_iz;
1034 dgInt32 m_iw;
1035 };
1036 };
1037
1038 static dgVector m_one;
1039 static dgVector m_wOne;
1040 static dgVector m_two;
1041 static dgVector m_half;
1042 static dgVector m_three;
1043 static dgVector m_negOne;
1044 static dgVector m_signMask;
1045 static dgVector m_triplexMask;
1046 } DG_GCC_VECTOR_ALIGMENT;
1047
1048 #endif
1049 #endif
1050
dgVector::dgVector
DG_INLINE dgVector(dgInt32 ix, dgInt32 iy, dgInt32 iz, dgInt32 iw)
Definition: dgVector.h:685
dgMemory.h
dgTemplateVector::operator-=
DG_INLINE dgTemplateVector< T > & operator-=(const dgTemplateVector< T > &A)
Definition: dgVector.h:99
dgBigVector::dgBigVector
DG_INLINE dgBigVector(const dgTemplateVector< dgFloat64 > &v)
Definition: dgVector.h:221
dgVector::m_type
__m128 m_type
Definition: dgVector.h:1021
DG_GCC_VECTOR_ALIGMENT
dgBigVector DG_GCC_VECTOR_ALIGMENT
dgVector::CrossProduct4
DG_INLINE dgVector CrossProduct4(const dgVector &A, const dgVector &B) const
Definition: dgVector.h:800
dgFloor
DG_INLINE dgFloat32 dgFloor(dgFloat32 x)
Definition: dgTypes.h:661
dgTemplateVector::dgTemplateVector
DG_INLINE dgTemplateVector(T x, T y, T z, T w)
Definition: dgVector.h:55
dgVector::dgVector
DG_INLINE dgVector(const __m128 type)
Definition: dgVector.h:648
dgVector::dgVector
DG_INLINE dgVector(const __m128i type)
Definition: dgVector.h:653
dgVector::Transpose4x4
static DG_INLINE void Transpose4x4(dgVector &dst0, dgVector &dst1, dgVector &dst2, dgVector &dst3, const dgVector &src0, const dgVector &src1, const dgVector &src2, const dgVector &src3)
Definition: dgVector.h:1003
dgBigVector::dgBigVector
DG_INLINE dgBigVector(const dgFloat64 *const ptr)
Definition: dgVector.h:241
dgDebug.h
PURMUT_MASK
#define PURMUT_MASK(w, z, y, x)
Definition: dgVector.h:641
dgVector::dgVector
DG_INLINE dgVector(const dgVector &copy)
Definition: dgVector.h:669
dgVector::m_half
static dgVector m_half
Definition: dgVector.h:1041
dgVector::m_iy
dgInt32 m_iy
Definition: dgVector.h:1032
DG_INLINE
#define DG_INLINE
Definition: dgTypes.h:178
dgAssert
#define dgAssert(x)
Definition: dgTypes.h:158
dgVector::CompProduct3
DG_INLINE dgVector CompProduct3(const dgVector &A) const
Definition: dgVector.h:839
dgFloat32
float dgFloat32
Definition: dgTypes.h:233
dgBigVector::dgBigVector
DG_INLINE dgBigVector()
Definition: dgVector.h:210
dgInt32
int dgInt32
Definition: dgTypes.h:218
dgVector::m_iw
dgInt32 m_iw
Definition: dgVector.h:1034
dgVector::m_ix
dgInt32 m_ix
Definition: dgVector.h:1031
dgVector::BroadcastZ
DG_INLINE dgVector BroadcastZ() const
Definition: dgVector.h:713
dgTemplateVector::CrossProduct4
DG_INLINE dgTemplateVector< T > CrossProduct4(const dgTemplateVector &A, const dgTemplateVector &B) const
Definition: dgVector.h:132
dgTemplateVector::operator+
DG_INLINE dgTemplateVector< T > operator+(const dgTemplateVector< T > &B) const
Definition: dgVector.h:84
dgVector
Definition: dgVector.h:639
dgVector::GetScalar
DG_INLINE dgFloat32 GetScalar() const
Definition: dgVector.h:691
dgTemplateVector::operator*
DG_INLINE dgTemplateVector< T > operator*(const dgTemplateVector< T > &B) const
Definition: dgVector.h:111
dgVector::m_iz
dgInt32 m_iz
Definition: dgVector.h:1033
dgTemplateVector::m_z
T m_z
Definition: dgVector.h:195
dgTemplateVector
Definition: dgVector.h:36
dgTrace
#define dgTrace(x)
Definition: dgDebug.h:36
dgVector::m_z
dgFloat32 m_z
Definition: dgVector.h:1027
dgVector::MoveHigh
DG_INLINE dgVector MoveHigh(const dgVector &data) const
Definition: dgVector.h:987
dgCheckVector
#define dgCheckVector(x)
Definition: dgVector.h:32
dgVector::GetSignMask
DG_INLINE dgInt32 GetSignMask() const
Definition: dgVector.h:971
dgVector::m_negOne
static dgVector m_negOne
Definition: dgVector.h:1043
dgVector::PackHigh
DG_INLINE dgVector PackHigh(const dgVector &data) const
Definition: dgVector.h:997
dgVector::Scale3
DG_INLINE dgVector Scale3(dgFloat32 s) const
Definition: dgVector.h:724
dgTemplateVector::m_y
T m_y
Definition: dgVector.h:194
DG_CLASS_ALLOCATOR
#define DG_CLASS_ALLOCATOR(allocator)
Definition: dgMemory.h:60
dgTemplateVector::dgTemplateVector
DG_INLINE dgTemplateVector(const T *const ptr)
Definition: dgVector.h:43
dgBigVector::dgBigVector
DG_INLINE dgBigVector(const dgVector &v)
Definition: dgVector.h:215
dgFloat64
double dgFloat64
Definition: dgTypes.h:224
dgTemplateVector::operator%
DG_INLINE T operator%(const dgTemplateVector< T > &A) const
Definition: dgVector.h:105
dgVector::Sqrt
DG_INLINE dgVector Sqrt() const
Definition: dgVector.h:907
dgVector::InvSqrt
DG_INLINE dgVector InvSqrt() const
Definition: dgVector.h:912
dgVector::MoveLow
DG_INLINE dgVector MoveLow(const dgVector &data) const
Definition: dgVector.h:982
dgVector::m_wOne
static dgVector m_wOne
Definition: dgVector.h:1039
dgVector::m_three
static dgVector m_three
Definition: dgVector.h:1042
dgVector::PackLow
DG_INLINE dgVector PackLow(const dgVector &data) const
Definition: dgVector.h:992
DG_MSC_VECTOR_ALIGMENT
#define DG_MSC_VECTOR_ALIGMENT
Definition: dgTypes.h:194
dgVector::dgVector
DG_INLINE dgVector(const dgFloat32 *const ptr)
Definition: dgVector.h:663
dgVector::m_triplexMask
static dgVector m_triplexMask
Definition: dgVector.h:1045
dgBigVector::dgBigVector
DG_INLINE dgBigVector(dgFloat64 x, dgFloat64 y, dgFloat64 z, dgFloat64 w)
Definition: dgVector.h:248
dgRsqrt
DG_INLINE dgFloat32 dgRsqrt(dgFloat32 x)
Definition: dgTypes.h:686
dgVector::m_x
dgFloat32 m_x
Definition: dgVector.h:1025
dgTemplateVector::dgTemplateVector
DG_INLINE dgTemplateVector()
Definition: dgVector.h:39
dgVector::BroadcastY
DG_INLINE dgVector BroadcastY() const
Definition: dgVector.h:708
dgStdafx.h
dgTemplateVector::operator[]
DG_INLINE T & operator[](dgInt32 i)
Definition: dgVector.h:60
dgVector::m_one
static dgVector m_one
Definition: dgVector.h:1038
dgVector::AddHorizontal
DG_INLINE dgVector AddHorizontal() const
Definition: dgVector.h:856
dgBigVector::dgBigVector
DG_INLINE dgBigVector(const dgBigVector &copy)
Definition: dgVector.h:227
dgTemplateVector::CompProduct4
DG_INLINE dgTemplateVector< T > CompProduct4(const dgTemplateVector< T > &A) const
Definition: dgVector.h:177
dgVector::dgVector
DG_INLINE dgVector(const dgFloat32 a)
Definition: dgVector.h:658
dgVector::InvMagSqrt
DG_INLINE dgVector InvMagSqrt() const
Definition: dgVector.h:918
dgVector::GetInt
DG_INLINE dgVector GetInt() const
Definition: dgVector.h:880
dgTemplateVector::operator+=
DG_INLINE dgTemplateVector< T > & operator+=(const dgTemplateVector< T > &A)
Definition: dgVector.h:89
s
sem_t s
Definition: semaphore3.c:78
dgVector::dgVector
DG_INLINE dgVector()
Definition: dgVector.h:644
dgVector::AndNot
DG_INLINE dgVector AndNot(const dgVector &data) const
Definition: dgVector.h:966
dgTemplateVector::DotProduct4
DG_INLINE dgTemplateVector< T > DotProduct4(const dgTemplateVector &A) const
Definition: dgVector.h:125
dgVector::m_typeInt
__m128i m_typeInt
Definition: dgVector.h:1022
dgVector::CompProduct4
DG_INLINE dgVector CompProduct4(const dgVector &A) const
Definition: dgVector.h:851
dgVector::Store
DG_INLINE void Store(dgFloat32 *const dst) const
Definition: dgVector.h:698
dgVector::m_signMask
static dgVector m_signMask
Definition: dgVector.h:1044
dgVector::Floor
DG_INLINE dgVector Floor() const
Definition: dgVector.h:891
dgBigVector::dgBigVector
DG_INLINE dgBigVector(const dgFloat32 *const ptr)
Definition: dgVector.h:234
dgTemplateVector::dgTemplateVector
DG_INLINE dgTemplateVector(const dgTemplateVector< T > &copy)
Definition: dgVector.h:49
dgVector::Abs
DG_INLINE dgVector Abs() const
Definition: dgVector.h:862
dgVector::m_two
static dgVector m_two
Definition: dgVector.h:1040
dgVector::DotProduct4
DG_INLINE dgVector DotProduct4(const dgVector &A) const
Definition: dgVector.h:783
dgTemplateVector::AddHorizontal
DG_INLINE dgTemplateVector< T > AddHorizontal() const
Definition: dgVector.h:118
dgVector::m_f
dgFloat32 m_f[4]
Definition: dgVector.h:1023
dgVector::TestZero
DG_INLINE dgVector TestZero() const
Definition: dgVector.h:886
dgTemplateVector::Scale4
DG_INLINE dgTemplateVector< T > Scale4(T scale) const
Definition: dgVector.h:79
dgSqrt
#define dgSqrt(x)
Definition: dgTypes.h:691
dgTemplateVector::Scale3
DG_INLINE dgTemplateVector< T > Scale3(T scale) const
Definition: dgVector.h:74
dgVector::dgVector
DG_INLINE dgVector(dgFloat32 x, dgFloat32 y, dgFloat32 z, dgFloat32 w)
Definition: dgVector.h:680
dgTypes.h
dgVector::BroadcastW
DG_INLINE dgVector BroadcastW() const
Definition: dgVector.h:718
dgVector::GetMin
dgVector GetMin(const dgVector &data) const
Definition: dgVector.h:874
dgVector::GetMax
dgVector GetMax(const dgVector &data) const
Definition: dgVector.h:869
dgVector::dgVector
DG_INLINE dgVector(const dgBigVector &copy)
Definition: dgVector.h:675
dgVector::m_w
dgFloat32 m_w
Definition: dgVector.h:1028
dgTemplateVector::operator-
DG_INLINE dgTemplateVector< T > operator-(const dgTemplateVector< T > &A) const
Definition: dgVector.h:94
dgTemplateVector::m_w
T m_w
Definition: dgVector.h:196
dgBigVector
Definition: dgVector.h:207
dgVector::BroadcastX
DG_INLINE dgVector BroadcastX() const
Definition: dgVector.h:703
dgVector::Reciproc
DG_INLINE dgVector Reciproc() const
Definition: dgVector.h:845
dgTemplateVector::CompProduct3
DG_INLINE dgTemplateVector< T > CompProduct3(const dgTemplateVector< T > &A) const
Definition: dgVector.h:171
dgTemplateVector::m_x
T m_x
Definition: dgVector.h:193
dgVector::ShiftTripleRight
DG_INLINE dgVector ShiftTripleRight() const
Definition: dgVector.h:976
dgVector::Scale4
DG_INLINE dgVector Scale4(dgFloat32 s) const
Definition: dgVector.h:730
dgVector::m_y
dgFloat32 m_y
Definition: dgVector.h:1026