Bullet Collision Detection & Physics Library
scalar/vec_aos.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 Sony Computer Entertainment Inc.
3  All rights reserved.
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 
15 */
16 
17 #ifndef _VECTORMATH_VEC_AOS_CPP_H
18 #define _VECTORMATH_VEC_AOS_CPP_H
19 
20 //-----------------------------------------------------------------------------
21 // Constants
22 
23 #define _VECTORMATH_SLERP_TOL 0.999f
24 
25 //-----------------------------------------------------------------------------
26 // Definitions
27 
28 #ifndef _VECTORMATH_INTERNAL_FUNCTIONS
29 #define _VECTORMATH_INTERNAL_FUNCTIONS
30 
31 #endif
32 
33 namespace Vectormath {
34 namespace Aos {
35 
36 inline Vector3::Vector3( const Vector3 & vec )
37 {
38  mX = vec.mX;
39  mY = vec.mY;
40  mZ = vec.mZ;
41 }
42 
43 inline Vector3::Vector3( float _x, float _y, float _z )
44 {
45  mX = _x;
46  mY = _y;
47  mZ = _z;
48 }
49 
50 inline Vector3::Vector3( const Point3 & pnt )
51 {
52  mX = pnt.getX();
53  mY = pnt.getY();
54  mZ = pnt.getZ();
55 }
56 
57 inline Vector3::Vector3( float scalar )
58 {
59  mX = scalar;
60  mY = scalar;
61  mZ = scalar;
62 }
63 
64 inline const Vector3 Vector3::xAxis( )
65 {
66  return Vector3( 1.0f, 0.0f, 0.0f );
67 }
68 
69 inline const Vector3 Vector3::yAxis( )
70 {
71  return Vector3( 0.0f, 1.0f, 0.0f );
72 }
73 
74 inline const Vector3 Vector3::zAxis( )
75 {
76  return Vector3( 0.0f, 0.0f, 1.0f );
77 }
78 
79 inline const Vector3 lerp( float t, const Vector3 & vec0, const Vector3 & vec1 )
80 {
81  return ( vec0 + ( ( vec1 - vec0 ) * t ) );
82 }
83 
84 inline const Vector3 slerp( float t, const Vector3 & unitVec0, const Vector3 & unitVec1 )
85 {
86  float recipSinAngle, scale0, scale1, cosAngle, angle;
87  cosAngle = dot( unitVec0, unitVec1 );
88  if ( cosAngle < _VECTORMATH_SLERP_TOL ) {
89  angle = acosf( cosAngle );
90  recipSinAngle = ( 1.0f / sinf( angle ) );
91  scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle );
92  scale1 = ( sinf( ( t * angle ) ) * recipSinAngle );
93  } else {
94  scale0 = ( 1.0f - t );
95  scale1 = t;
96  }
97  return ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) );
98 }
99 
100 inline void loadXYZ( Vector3 & vec, const float * fptr )
101 {
102  vec = Vector3( fptr[0], fptr[1], fptr[2] );
103 }
104 
105 inline void storeXYZ( const Vector3 & vec, float * fptr )
106 {
107  fptr[0] = vec.getX();
108  fptr[1] = vec.getY();
109  fptr[2] = vec.getZ();
110 }
111 
112 inline void loadHalfFloats( Vector3 & vec, const unsigned short * hfptr )
113 {
114  union Data32 {
115  unsigned int u32;
116  float f32;
117  };
118 
119  for (int i = 0; i < 3; i++) {
120  unsigned short fp16 = hfptr[i];
121  unsigned int sign = fp16 >> 15;
122  unsigned int exponent = (fp16 >> 10) & ((1 << 5) - 1);
123  unsigned int mantissa = fp16 & ((1 << 10) - 1);
124 
125  if (exponent == 0) {
126  // zero
127  mantissa = 0;
128 
129  } else if (exponent == 31) {
130  // infinity or nan -> infinity
131  exponent = 255;
132  mantissa = 0;
133 
134  } else {
135  exponent += 127 - 15;
136  mantissa <<= 13;
137  }
138 
139  Data32 d;
140  d.u32 = (sign << 31) | (exponent << 23) | mantissa;
141  vec[i] = d.f32;
142  }
143 }
144 
145 inline void storeHalfFloats( const Vector3 & vec, unsigned short * hfptr )
146 {
147  union Data32 {
148  unsigned int u32;
149  float f32;
150  };
151 
152  for (int i = 0; i < 3; i++) {
153  Data32 d;
154  d.f32 = vec[i];
155 
156  unsigned int sign = d.u32 >> 31;
157  unsigned int exponent = (d.u32 >> 23) & ((1 << 8) - 1);
158  unsigned int mantissa = d.u32 & ((1 << 23) - 1);;
159 
160  if (exponent == 0) {
161  // zero or denorm -> zero
162  mantissa = 0;
163 
164  } else if (exponent == 255 && mantissa != 0) {
165  // nan -> infinity
166  exponent = 31;
167  mantissa = 0;
168 
169  } else if (exponent >= 127 - 15 + 31) {
170  // overflow or infinity -> infinity
171  exponent = 31;
172  mantissa = 0;
173 
174  } else if (exponent <= 127 - 15) {
175  // underflow -> zero
176  exponent = 0;
177  mantissa = 0;
178 
179  } else {
180  exponent -= 127 - 15;
181  mantissa >>= 13;
182  }
183 
184  hfptr[i] = (unsigned short)((sign << 15) | (exponent << 10) | mantissa);
185  }
186 }
187 
188 inline Vector3 & Vector3::operator =( const Vector3 & vec )
189 {
190  mX = vec.mX;
191  mY = vec.mY;
192  mZ = vec.mZ;
193  return *this;
194 }
195 
196 inline Vector3 & Vector3::setX( float _x )
197 {
198  mX = _x;
199  return *this;
200 }
201 
202 inline float Vector3::getX( ) const
203 {
204  return mX;
205 }
206 
207 inline Vector3 & Vector3::setY( float _y )
208 {
209  mY = _y;
210  return *this;
211 }
212 
213 inline float Vector3::getY( ) const
214 {
215  return mY;
216 }
217 
218 inline Vector3 & Vector3::setZ( float _z )
219 {
220  mZ = _z;
221  return *this;
222 }
223 
224 inline float Vector3::getZ( ) const
225 {
226  return mZ;
227 }
228 
229 inline Vector3 & Vector3::setElem( int idx, float value )
230 {
231  *(&mX + idx) = value;
232  return *this;
233 }
234 
235 inline float Vector3::getElem( int idx ) const
236 {
237  return *(&mX + idx);
238 }
239 
240 inline float & Vector3::operator []( int idx )
241 {
242  return *(&mX + idx);
243 }
244 
245 inline float Vector3::operator []( int idx ) const
246 {
247  return *(&mX + idx);
248 }
249 
250 inline const Vector3 Vector3::operator +( const Vector3 & vec ) const
251 {
252  return Vector3(
253  ( mX + vec.mX ),
254  ( mY + vec.mY ),
255  ( mZ + vec.mZ )
256  );
257 }
258 
259 inline const Vector3 Vector3::operator -( const Vector3 & vec ) const
260 {
261  return Vector3(
262  ( mX - vec.mX ),
263  ( mY - vec.mY ),
264  ( mZ - vec.mZ )
265  );
266 }
267 
268 inline const Point3 Vector3::operator +( const Point3 & pnt ) const
269 {
270  return Point3(
271  ( mX + pnt.getX() ),
272  ( mY + pnt.getY() ),
273  ( mZ + pnt.getZ() )
274  );
275 }
276 
277 inline const Vector3 Vector3::operator *( float scalar ) const
278 {
279  return Vector3(
280  ( mX * scalar ),
281  ( mY * scalar ),
282  ( mZ * scalar )
283  );
284 }
285 
286 inline Vector3 & Vector3::operator +=( const Vector3 & vec )
287 {
288  *this = *this + vec;
289  return *this;
290 }
291 
292 inline Vector3 & Vector3::operator -=( const Vector3 & vec )
293 {
294  *this = *this - vec;
295  return *this;
296 }
297 
298 inline Vector3 & Vector3::operator *=( float scalar )
299 {
300  *this = *this * scalar;
301  return *this;
302 }
303 
304 inline const Vector3 Vector3::operator /( float scalar ) const
305 {
306  return Vector3(
307  ( mX / scalar ),
308  ( mY / scalar ),
309  ( mZ / scalar )
310  );
311 }
312 
313 inline Vector3 & Vector3::operator /=( float scalar )
314 {
315  *this = *this / scalar;
316  return *this;
317 }
318 
319 inline const Vector3 Vector3::operator -( ) const
320 {
321  return Vector3(
322  -mX,
323  -mY,
324  -mZ
325  );
326 }
327 
328 inline const Vector3 operator *( float scalar, const Vector3 & vec )
329 {
330  return vec * scalar;
331 }
332 
333 inline const Vector3 mulPerElem( const Vector3 & vec0, const Vector3 & vec1 )
334 {
335  return Vector3(
336  ( vec0.getX() * vec1.getX() ),
337  ( vec0.getY() * vec1.getY() ),
338  ( vec0.getZ() * vec1.getZ() )
339  );
340 }
341 
342 inline const Vector3 divPerElem( const Vector3 & vec0, const Vector3 & vec1 )
343 {
344  return Vector3(
345  ( vec0.getX() / vec1.getX() ),
346  ( vec0.getY() / vec1.getY() ),
347  ( vec0.getZ() / vec1.getZ() )
348  );
349 }
350 
351 inline const Vector3 recipPerElem( const Vector3 & vec )
352 {
353  return Vector3(
354  ( 1.0f / vec.getX() ),
355  ( 1.0f / vec.getY() ),
356  ( 1.0f / vec.getZ() )
357  );
358 }
359 
360 inline const Vector3 sqrtPerElem( const Vector3 & vec )
361 {
362  return Vector3(
363  sqrtf( vec.getX() ),
364  sqrtf( vec.getY() ),
365  sqrtf( vec.getZ() )
366  );
367 }
368 
369 inline const Vector3 rsqrtPerElem( const Vector3 & vec )
370 {
371  return Vector3(
372  ( 1.0f / sqrtf( vec.getX() ) ),
373  ( 1.0f / sqrtf( vec.getY() ) ),
374  ( 1.0f / sqrtf( vec.getZ() ) )
375  );
376 }
377 
378 inline const Vector3 absPerElem( const Vector3 & vec )
379 {
380  return Vector3(
381  fabsf( vec.getX() ),
382  fabsf( vec.getY() ),
383  fabsf( vec.getZ() )
384  );
385 }
386 
387 inline const Vector3 copySignPerElem( const Vector3 & vec0, const Vector3 & vec1 )
388 {
389  return Vector3(
390  ( vec1.getX() < 0.0f )? -fabsf( vec0.getX() ) : fabsf( vec0.getX() ),
391  ( vec1.getY() < 0.0f )? -fabsf( vec0.getY() ) : fabsf( vec0.getY() ),
392  ( vec1.getZ() < 0.0f )? -fabsf( vec0.getZ() ) : fabsf( vec0.getZ() )
393  );
394 }
395 
396 inline const Vector3 maxPerElem( const Vector3 & vec0, const Vector3 & vec1 )
397 {
398  return Vector3(
399  (vec0.getX() > vec1.getX())? vec0.getX() : vec1.getX(),
400  (vec0.getY() > vec1.getY())? vec0.getY() : vec1.getY(),
401  (vec0.getZ() > vec1.getZ())? vec0.getZ() : vec1.getZ()
402  );
403 }
404 
405 inline float maxElem( const Vector3 & vec )
406 {
407  float result;
408  result = (vec.getX() > vec.getY())? vec.getX() : vec.getY();
409  result = (vec.getZ() > result)? vec.getZ() : result;
410  return result;
411 }
412 
413 inline const Vector3 minPerElem( const Vector3 & vec0, const Vector3 & vec1 )
414 {
415  return Vector3(
416  (vec0.getX() < vec1.getX())? vec0.getX() : vec1.getX(),
417  (vec0.getY() < vec1.getY())? vec0.getY() : vec1.getY(),
418  (vec0.getZ() < vec1.getZ())? vec0.getZ() : vec1.getZ()
419  );
420 }
421 
422 inline float minElem( const Vector3 & vec )
423 {
424  float result;
425  result = (vec.getX() < vec.getY())? vec.getX() : vec.getY();
426  result = (vec.getZ() < result)? vec.getZ() : result;
427  return result;
428 }
429 
430 inline float sum( const Vector3 & vec )
431 {
432  float result;
433  result = ( vec.getX() + vec.getY() );
434  result = ( result + vec.getZ() );
435  return result;
436 }
437 
438 inline float dot( const Vector3 & vec0, const Vector3 & vec1 )
439 {
440  float result;
441  result = ( vec0.getX() * vec1.getX() );
442  result = ( result + ( vec0.getY() * vec1.getY() ) );
443  result = ( result + ( vec0.getZ() * vec1.getZ() ) );
444  return result;
445 }
446 
447 inline float lengthSqr( const Vector3 & vec )
448 {
449  float result;
450  result = ( vec.getX() * vec.getX() );
451  result = ( result + ( vec.getY() * vec.getY() ) );
452  result = ( result + ( vec.getZ() * vec.getZ() ) );
453  return result;
454 }
455 
456 inline float length( const Vector3 & vec )
457 {
458  return ::sqrtf( lengthSqr( vec ) );
459 }
460 
461 inline const Vector3 normalize( const Vector3 & vec )
462 {
463  float lenSqr, lenInv;
464  lenSqr = lengthSqr( vec );
465  lenInv = ( 1.0f / sqrtf( lenSqr ) );
466  return Vector3(
467  ( vec.getX() * lenInv ),
468  ( vec.getY() * lenInv ),
469  ( vec.getZ() * lenInv )
470  );
471 }
472 
473 inline const Vector3 cross( const Vector3 & vec0, const Vector3 & vec1 )
474 {
475  return Vector3(
476  ( ( vec0.getY() * vec1.getZ() ) - ( vec0.getZ() * vec1.getY() ) ),
477  ( ( vec0.getZ() * vec1.getX() ) - ( vec0.getX() * vec1.getZ() ) ),
478  ( ( vec0.getX() * vec1.getY() ) - ( vec0.getY() * vec1.getX() ) )
479  );
480 }
481 
482 inline const Vector3 select( const Vector3 & vec0, const Vector3 & vec1, bool select1 )
483 {
484  return Vector3(
485  ( select1 )? vec1.getX() : vec0.getX(),
486  ( select1 )? vec1.getY() : vec0.getY(),
487  ( select1 )? vec1.getZ() : vec0.getZ()
488  );
489 }
490 
491 #ifdef _VECTORMATH_DEBUG
492 
493 inline void print( const Vector3 & vec )
494 {
495  printf( "( %f %f %f )\n", vec.getX(), vec.getY(), vec.getZ() );
496 }
497 
498 inline void print( const Vector3 & vec, const char * name )
499 {
500  printf( "%s: ( %f %f %f )\n", name, vec.getX(), vec.getY(), vec.getZ() );
501 }
502 
503 #endif
504 
505 inline Vector4::Vector4( const Vector4 & vec )
506 {
507  mX = vec.mX;
508  mY = vec.mY;
509  mZ = vec.mZ;
510  mW = vec.mW;
511 }
512 
513 inline Vector4::Vector4( float _x, float _y, float _z, float _w )
514 {
515  mX = _x;
516  mY = _y;
517  mZ = _z;
518  mW = _w;
519 }
520 
521 inline Vector4::Vector4( const Vector3 & xyz, float _w )
522 {
523  this->setXYZ( xyz );
524  this->setW( _w );
525 }
526 
527 inline Vector4::Vector4( const Vector3 & vec )
528 {
529  mX = vec.getX();
530  mY = vec.getY();
531  mZ = vec.getZ();
532  mW = 0.0f;
533 }
534 
535 inline Vector4::Vector4( const Point3 & pnt )
536 {
537  mX = pnt.getX();
538  mY = pnt.getY();
539  mZ = pnt.getZ();
540  mW = 1.0f;
541 }
542 
543 inline Vector4::Vector4( const Quat & quat )
544 {
545  mX = quat.getX();
546  mY = quat.getY();
547  mZ = quat.getZ();
548  mW = quat.getW();
549 }
550 
551 inline Vector4::Vector4( float scalar )
552 {
553  mX = scalar;
554  mY = scalar;
555  mZ = scalar;
556  mW = scalar;
557 }
558 
559 inline const Vector4 Vector4::xAxis( )
560 {
561  return Vector4( 1.0f, 0.0f, 0.0f, 0.0f );
562 }
563 
564 inline const Vector4 Vector4::yAxis( )
565 {
566  return Vector4( 0.0f, 1.0f, 0.0f, 0.0f );
567 }
568 
569 inline const Vector4 Vector4::zAxis( )
570 {
571  return Vector4( 0.0f, 0.0f, 1.0f, 0.0f );
572 }
573 
574 inline const Vector4 Vector4::wAxis( )
575 {
576  return Vector4( 0.0f, 0.0f, 0.0f, 1.0f );
577 }
578 
579 inline const Vector4 lerp( float t, const Vector4 & vec0, const Vector4 & vec1 )
580 {
581  return ( vec0 + ( ( vec1 - vec0 ) * t ) );
582 }
583 
584 inline const Vector4 slerp( float t, const Vector4 & unitVec0, const Vector4 & unitVec1 )
585 {
586  float recipSinAngle, scale0, scale1, cosAngle, angle;
587  cosAngle = dot( unitVec0, unitVec1 );
588  if ( cosAngle < _VECTORMATH_SLERP_TOL ) {
589  angle = acosf( cosAngle );
590  recipSinAngle = ( 1.0f / sinf( angle ) );
591  scale0 = ( sinf( ( ( 1.0f - t ) * angle ) ) * recipSinAngle );
592  scale1 = ( sinf( ( t * angle ) ) * recipSinAngle );
593  } else {
594  scale0 = ( 1.0f - t );
595  scale1 = t;
596  }
597  return ( ( unitVec0 * scale0 ) + ( unitVec1 * scale1 ) );
598 }
599 
600 inline void loadXYZW( Vector4 & vec, const float * fptr )
601 {
602  vec = Vector4( fptr[0], fptr[1], fptr[2], fptr[3] );
603 }
604 
605 inline void storeXYZW( const Vector4 & vec, float * fptr )
606 {
607  fptr[0] = vec.getX();
608  fptr[1] = vec.getY();
609  fptr[2] = vec.getZ();
610  fptr[3] = vec.getW();
611 }
612 
613 inline void loadHalfFloats( Vector4 & vec, const unsigned short * hfptr )
614 {
615  union Data32 {
616  unsigned int u32;
617  float f32;
618  };
619 
620  for (int i = 0; i < 4; i++) {
621  unsigned short fp16 = hfptr[i];
622  unsigned int sign = fp16 >> 15;
623  unsigned int exponent = (fp16 >> 10) & ((1 << 5) - 1);
624  unsigned int mantissa = fp16 & ((1 << 10) - 1);
625 
626  if (exponent == 0) {
627  // zero
628  mantissa = 0;
629 
630  } else if (exponent == 31) {
631  // infinity or nan -> infinity
632  exponent = 255;
633  mantissa = 0;
634 
635  } else {
636  exponent += 127 - 15;
637  mantissa <<= 13;
638  }
639 
640  Data32 d;
641  d.u32 = (sign << 31) | (exponent << 23) | mantissa;
642  vec[i] = d.f32;
643  }
644 }
645 
646 inline void storeHalfFloats( const Vector4 & vec, unsigned short * hfptr )
647 {
648  union Data32 {
649  unsigned int u32;
650  float f32;
651  };
652 
653  for (int i = 0; i < 4; i++) {
654  Data32 d;
655  d.f32 = vec[i];
656 
657  unsigned int sign = d.u32 >> 31;
658  unsigned int exponent = (d.u32 >> 23) & ((1 << 8) - 1);
659  unsigned int mantissa = d.u32 & ((1 << 23) - 1);;
660 
661  if (exponent == 0) {
662  // zero or denorm -> zero
663  mantissa = 0;
664 
665  } else if (exponent == 255 && mantissa != 0) {
666  // nan -> infinity
667  exponent = 31;
668  mantissa = 0;
669 
670  } else if (exponent >= 127 - 15 + 31) {
671  // overflow or infinity -> infinity
672  exponent = 31;
673  mantissa = 0;
674 
675  } else if (exponent <= 127 - 15) {
676  // underflow -> zero
677  exponent = 0;
678  mantissa = 0;
679 
680  } else {
681  exponent -= 127 - 15;
682  mantissa >>= 13;
683  }
684 
685  hfptr[i] = (unsigned short)((sign << 15) | (exponent << 10) | mantissa);
686  }
687 }
688 
689 inline Vector4 & Vector4::operator =( const Vector4 & vec )
690 {
691  mX = vec.mX;
692  mY = vec.mY;
693  mZ = vec.mZ;
694  mW = vec.mW;
695  return *this;
696 }
697 
698 inline Vector4 & Vector4::setXYZ( const Vector3 & vec )
699 {
700  mX = vec.getX();
701  mY = vec.getY();
702  mZ = vec.getZ();
703  return *this;
704 }
705 
706 inline const Vector3 Vector4::getXYZ( ) const
707 {
708  return Vector3( mX, mY, mZ );
709 }
710 
711 inline Vector4 & Vector4::setX( float _x )
712 {
713  mX = _x;
714  return *this;
715 }
716 
717 inline float Vector4::getX( ) const
718 {
719  return mX;
720 }
721 
722 inline Vector4 & Vector4::setY( float _y )
723 {
724  mY = _y;
725  return *this;
726 }
727 
728 inline float Vector4::getY( ) const
729 {
730  return mY;
731 }
732 
733 inline Vector4 & Vector4::setZ( float _z )
734 {
735  mZ = _z;
736  return *this;
737 }
738 
739 inline float Vector4::getZ( ) const
740 {
741  return mZ;
742 }
743 
744 inline Vector4 & Vector4::setW( float _w )
745 {
746  mW = _w;
747  return *this;
748 }
749 
750 inline float Vector4::getW( ) const
751 {
752  return mW;
753 }
754 
755 inline Vector4 & Vector4::setElem( int idx, float value )
756 {
757  *(&mX + idx) = value;
758  return *this;
759 }
760 
761 inline float Vector4::getElem( int idx ) const
762 {
763  return *(&mX + idx);
764 }
765 
766 inline float & Vector4::operator []( int idx )
767 {
768  return *(&mX + idx);
769 }
770 
771 inline float Vector4::operator []( int idx ) const
772 {
773  return *(&mX + idx);
774 }
775 
776 inline const Vector4 Vector4::operator +( const Vector4 & vec ) const
777 {
778  return Vector4(
779  ( mX + vec.mX ),
780  ( mY + vec.mY ),
781  ( mZ + vec.mZ ),
782  ( mW + vec.mW )
783  );
784 }
785 
786 inline const Vector4 Vector4::operator -( const Vector4 & vec ) const
787 {
788  return Vector4(
789  ( mX - vec.mX ),
790  ( mY - vec.mY ),
791  ( mZ - vec.mZ ),
792  ( mW - vec.mW )
793  );
794 }
795 
796 inline const Vector4 Vector4::operator *( float scalar ) const
797 {
798  return Vector4(
799  ( mX * scalar ),
800  ( mY * scalar ),
801  ( mZ * scalar ),
802  ( mW * scalar )
803  );
804 }
805 
806 inline Vector4 & Vector4::operator +=( const Vector4 & vec )
807 {
808  *this = *this + vec;
809  return *this;
810 }
811 
812 inline Vector4 & Vector4::operator -=( const Vector4 & vec )
813 {
814  *this = *this - vec;
815  return *this;
816 }
817 
818 inline Vector4 & Vector4::operator *=( float scalar )
819 {
820  *this = *this * scalar;
821  return *this;
822 }
823 
824 inline const Vector4 Vector4::operator /( float scalar ) const
825 {
826  return Vector4(
827  ( mX / scalar ),
828  ( mY / scalar ),
829  ( mZ / scalar ),
830  ( mW / scalar )
831  );
832 }
833 
834 inline Vector4 & Vector4::operator /=( float scalar )
835 {
836  *this = *this / scalar;
837  return *this;
838 }
839 
840 inline const Vector4 Vector4::operator -( ) const
841 {
842  return Vector4(
843  -mX,
844  -mY,
845  -mZ,
846  -mW
847  );
848 }
849 
850 inline const Vector4 operator *( float scalar, const Vector4 & vec )
851 {
852  return vec * scalar;
853 }
854 
855 inline const Vector4 mulPerElem( const Vector4 & vec0, const Vector4 & vec1 )
856 {
857  return Vector4(
858  ( vec0.getX() * vec1.getX() ),
859  ( vec0.getY() * vec1.getY() ),
860  ( vec0.getZ() * vec1.getZ() ),
861  ( vec0.getW() * vec1.getW() )
862  );
863 }
864 
865 inline const Vector4 divPerElem( const Vector4 & vec0, const Vector4 & vec1 )
866 {
867  return Vector4(
868  ( vec0.getX() / vec1.getX() ),
869  ( vec0.getY() / vec1.getY() ),
870  ( vec0.getZ() / vec1.getZ() ),
871  ( vec0.getW() / vec1.getW() )
872  );
873 }
874 
875 inline const Vector4 recipPerElem( const Vector4 & vec )
876 {
877  return Vector4(
878  ( 1.0f / vec.getX() ),
879  ( 1.0f / vec.getY() ),
880  ( 1.0f / vec.getZ() ),
881  ( 1.0f / vec.getW() )
882  );
883 }
884 
885 inline const Vector4 sqrtPerElem( const Vector4 & vec )
886 {
887  return Vector4(
888  sqrtf( vec.getX() ),
889  sqrtf( vec.getY() ),
890  sqrtf( vec.getZ() ),
891  sqrtf( vec.getW() )
892  );
893 }
894 
895 inline const Vector4 rsqrtPerElem( const Vector4 & vec )
896 {
897  return Vector4(
898  ( 1.0f / sqrtf( vec.getX() ) ),
899  ( 1.0f / sqrtf( vec.getY() ) ),
900  ( 1.0f / sqrtf( vec.getZ() ) ),
901  ( 1.0f / sqrtf( vec.getW() ) )
902  );
903 }
904 
905 inline const Vector4 absPerElem( const Vector4 & vec )
906 {
907  return Vector4(
908  fabsf( vec.getX() ),
909  fabsf( vec.getY() ),
910  fabsf( vec.getZ() ),
911  fabsf( vec.getW() )
912  );
913 }
914 
915 inline const Vector4 copySignPerElem( const Vector4 & vec0, const Vector4 & vec1 )
916 {
917  return Vector4(
918  ( vec1.getX() < 0.0f )? -fabsf( vec0.getX() ) : fabsf( vec0.getX() ),
919  ( vec1.getY() < 0.0f )? -fabsf( vec0.getY() ) : fabsf( vec0.getY() ),
920  ( vec1.getZ() < 0.0f )? -fabsf( vec0.getZ() ) : fabsf( vec0.getZ() ),
921  ( vec1.getW() < 0.0f )? -fabsf( vec0.getW() ) : fabsf( vec0.getW() )
922  );
923 }
924 
925 inline const Vector4 maxPerElem( const Vector4 & vec0, const Vector4 & vec1 )
926 {
927  return Vector4(
928  (vec0.getX() > vec1.getX())? vec0.getX() : vec1.getX(),
929  (vec0.getY() > vec1.getY())? vec0.getY() : vec1.getY(),
930  (vec0.getZ() > vec1.getZ())? vec0.getZ() : vec1.getZ(),
931  (vec0.getW() > vec1.getW())? vec0.getW() : vec1.getW()
932  );
933 }
934 
935 inline float maxElem( const Vector4 & vec )
936 {
937  float result;
938  result = (vec.getX() > vec.getY())? vec.getX() : vec.getY();
939  result = (vec.getZ() > result)? vec.getZ() : result;
940  result = (vec.getW() > result)? vec.getW() : result;
941  return result;
942 }
943 
944 inline const Vector4 minPerElem( const Vector4 & vec0, const Vector4 & vec1 )
945 {
946  return Vector4(
947  (vec0.getX() < vec1.getX())? vec0.getX() : vec1.getX(),
948  (vec0.getY() < vec1.getY())? vec0.getY() : vec1.getY(),
949  (vec0.getZ() < vec1.getZ())? vec0.getZ() : vec1.getZ(),
950  (vec0.getW() < vec1.getW())? vec0.getW() : vec1.getW()
951  );
952 }
953 
954 inline float minElem( const Vector4 & vec )
955 {
956  float result;
957  result = (vec.getX() < vec.getY())? vec.getX() : vec.getY();
958  result = (vec.getZ() < result)? vec.getZ() : result;
959  result = (vec.getW() < result)? vec.getW() : result;
960  return result;
961 }
962 
963 inline float sum( const Vector4 & vec )
964 {
965  float result;
966  result = ( vec.getX() + vec.getY() );
967  result = ( result + vec.getZ() );
968  result = ( result + vec.getW() );
969  return result;
970 }
971 
972 inline float dot( const Vector4 & vec0, const Vector4 & vec1 )
973 {
974  float result;
975  result = ( vec0.getX() * vec1.getX() );
976  result = ( result + ( vec0.getY() * vec1.getY() ) );
977  result = ( result + ( vec0.getZ() * vec1.getZ() ) );
978  result = ( result + ( vec0.getW() * vec1.getW() ) );
979  return result;
980 }
981 
982 inline float lengthSqr( const Vector4 & vec )
983 {
984  float result;
985  result = ( vec.getX() * vec.getX() );
986  result = ( result + ( vec.getY() * vec.getY() ) );
987  result = ( result + ( vec.getZ() * vec.getZ() ) );
988  result = ( result + ( vec.getW() * vec.getW() ) );
989  return result;
990 }
991 
992 inline float length( const Vector4 & vec )
993 {
994  return ::sqrtf( lengthSqr( vec ) );
995 }
996 
997 inline const Vector4 normalize( const Vector4 & vec )
998 {
999  float lenSqr, lenInv;
1000  lenSqr = lengthSqr( vec );
1001  lenInv = ( 1.0f / sqrtf( lenSqr ) );
1002  return Vector4(
1003  ( vec.getX() * lenInv ),
1004  ( vec.getY() * lenInv ),
1005  ( vec.getZ() * lenInv ),
1006  ( vec.getW() * lenInv )
1007  );
1008 }
1009 
1010 inline const Vector4 select( const Vector4 & vec0, const Vector4 & vec1, bool select1 )
1011 {
1012  return Vector4(
1013  ( select1 )? vec1.getX() : vec0.getX(),
1014  ( select1 )? vec1.getY() : vec0.getY(),
1015  ( select1 )? vec1.getZ() : vec0.getZ(),
1016  ( select1 )? vec1.getW() : vec0.getW()
1017  );
1018 }
1019 
1020 #ifdef _VECTORMATH_DEBUG
1021 
1022 inline void print( const Vector4 & vec )
1023 {
1024  printf( "( %f %f %f %f )\n", vec.getX(), vec.getY(), vec.getZ(), vec.getW() );
1025 }
1026 
1027 inline void print( const Vector4 & vec, const char * name )
1028 {
1029  printf( "%s: ( %f %f %f %f )\n", name, vec.getX(), vec.getY(), vec.getZ(), vec.getW() );
1030 }
1031 
1032 #endif
1033 
1034 inline Point3::Point3( const Point3 & pnt )
1035 {
1036  mX = pnt.mX;
1037  mY = pnt.mY;
1038  mZ = pnt.mZ;
1039 }
1040 
1041 inline Point3::Point3( float _x, float _y, float _z )
1042 {
1043  mX = _x;
1044  mY = _y;
1045  mZ = _z;
1046 }
1047 
1048 inline Point3::Point3( const Vector3 & vec )
1049 {
1050  mX = vec.getX();
1051  mY = vec.getY();
1052  mZ = vec.getZ();
1053 }
1054 
1055 inline Point3::Point3( float scalar )
1056 {
1057  mX = scalar;
1058  mY = scalar;
1059  mZ = scalar;
1060 }
1061 
1062 inline const Point3 lerp( float t, const Point3 & pnt0, const Point3 & pnt1 )
1063 {
1064  return ( pnt0 + ( ( pnt1 - pnt0 ) * t ) );
1065 }
1066 
1067 inline void loadXYZ( Point3 & pnt, const float * fptr )
1068 {
1069  pnt = Point3( fptr[0], fptr[1], fptr[2] );
1070 }
1071 
1072 inline void storeXYZ( const Point3 & pnt, float * fptr )
1073 {
1074  fptr[0] = pnt.getX();
1075  fptr[1] = pnt.getY();
1076  fptr[2] = pnt.getZ();
1077 }
1078 
1079 inline void loadHalfFloats( Point3 & vec, const unsigned short * hfptr )
1080 {
1081  union Data32 {
1082  unsigned int u32;
1083  float f32;
1084  };
1085 
1086  for (int i = 0; i < 3; i++) {
1087  unsigned short fp16 = hfptr[i];
1088  unsigned int sign = fp16 >> 15;
1089  unsigned int exponent = (fp16 >> 10) & ((1 << 5) - 1);
1090  unsigned int mantissa = fp16 & ((1 << 10) - 1);
1091 
1092  if (exponent == 0) {
1093  // zero
1094  mantissa = 0;
1095 
1096  } else if (exponent == 31) {
1097  // infinity or nan -> infinity
1098  exponent = 255;
1099  mantissa = 0;
1100 
1101  } else {
1102  exponent += 127 - 15;
1103  mantissa <<= 13;
1104  }
1105 
1106  Data32 d;
1107  d.u32 = (sign << 31) | (exponent << 23) | mantissa;
1108  vec[i] = d.f32;
1109  }
1110 }
1111 
1112 inline void storeHalfFloats( const Point3 & vec, unsigned short * hfptr )
1113 {
1114  union Data32 {
1115  unsigned int u32;
1116  float f32;
1117  };
1118 
1119  for (int i = 0; i < 3; i++) {
1120  Data32 d;
1121  d.f32 = vec[i];
1122 
1123  unsigned int sign = d.u32 >> 31;
1124  unsigned int exponent = (d.u32 >> 23) & ((1 << 8) - 1);
1125  unsigned int mantissa = d.u32 & ((1 << 23) - 1);;
1126 
1127  if (exponent == 0) {
1128  // zero or denorm -> zero
1129  mantissa = 0;
1130 
1131  } else if (exponent == 255 && mantissa != 0) {
1132  // nan -> infinity
1133  exponent = 31;
1134  mantissa = 0;
1135 
1136  } else if (exponent >= 127 - 15 + 31) {
1137  // overflow or infinity -> infinity
1138  exponent = 31;
1139  mantissa = 0;
1140 
1141  } else if (exponent <= 127 - 15) {
1142  // underflow -> zero
1143  exponent = 0;
1144  mantissa = 0;
1145 
1146  } else {
1147  exponent -= 127 - 15;
1148  mantissa >>= 13;
1149  }
1150 
1151  hfptr[i] = (unsigned short)((sign << 15) | (exponent << 10) | mantissa);
1152  }
1153 }
1154 
1155 inline Point3 & Point3::operator =( const Point3 & pnt )
1156 {
1157  mX = pnt.mX;
1158  mY = pnt.mY;
1159  mZ = pnt.mZ;
1160  return *this;
1161 }
1162 
1163 inline Point3 & Point3::setX( float _x )
1164 {
1165  mX = _x;
1166  return *this;
1167 }
1168 
1169 inline float Point3::getX( ) const
1170 {
1171  return mX;
1172 }
1173 
1174 inline Point3 & Point3::setY( float _y )
1175 {
1176  mY = _y;
1177  return *this;
1178 }
1179 
1180 inline float Point3::getY( ) const
1181 {
1182  return mY;
1183 }
1184 
1185 inline Point3 & Point3::setZ( float _z )
1186 {
1187  mZ = _z;
1188  return *this;
1189 }
1190 
1191 inline float Point3::getZ( ) const
1192 {
1193  return mZ;
1194 }
1195 
1196 inline Point3 & Point3::setElem( int idx, float value )
1197 {
1198  *(&mX + idx) = value;
1199  return *this;
1200 }
1201 
1202 inline float Point3::getElem( int idx ) const
1203 {
1204  return *(&mX + idx);
1205 }
1206 
1207 inline float & Point3::operator []( int idx )
1208 {
1209  return *(&mX + idx);
1210 }
1211 
1212 inline float Point3::operator []( int idx ) const
1213 {
1214  return *(&mX + idx);
1215 }
1216 
1217 inline const Vector3 Point3::operator -( const Point3 & pnt ) const
1218 {
1219  return Vector3(
1220  ( mX - pnt.mX ),
1221  ( mY - pnt.mY ),
1222  ( mZ - pnt.mZ )
1223  );
1224 }
1225 
1226 inline const Point3 Point3::operator +( const Vector3 & vec ) const
1227 {
1228  return Point3(
1229  ( mX + vec.getX() ),
1230  ( mY + vec.getY() ),
1231  ( mZ + vec.getZ() )
1232  );
1233 }
1234 
1235 inline const Point3 Point3::operator -( const Vector3 & vec ) const
1236 {
1237  return Point3(
1238  ( mX - vec.getX() ),
1239  ( mY - vec.getY() ),
1240  ( mZ - vec.getZ() )
1241  );
1242 }
1243 
1244 inline Point3 & Point3::operator +=( const Vector3 & vec )
1245 {
1246  *this = *this + vec;
1247  return *this;
1248 }
1249 
1250 inline Point3 & Point3::operator -=( const Vector3 & vec )
1251 {
1252  *this = *this - vec;
1253  return *this;
1254 }
1255 
1256 inline const Point3 mulPerElem( const Point3 & pnt0, const Point3 & pnt1 )
1257 {
1258  return Point3(
1259  ( pnt0.getX() * pnt1.getX() ),
1260  ( pnt0.getY() * pnt1.getY() ),
1261  ( pnt0.getZ() * pnt1.getZ() )
1262  );
1263 }
1264 
1265 inline const Point3 divPerElem( const Point3 & pnt0, const Point3 & pnt1 )
1266 {
1267  return Point3(
1268  ( pnt0.getX() / pnt1.getX() ),
1269  ( pnt0.getY() / pnt1.getY() ),
1270  ( pnt0.getZ() / pnt1.getZ() )
1271  );
1272 }
1273 
1274 inline const Point3 recipPerElem( const Point3 & pnt )
1275 {
1276  return Point3(
1277  ( 1.0f / pnt.getX() ),
1278  ( 1.0f / pnt.getY() ),
1279  ( 1.0f / pnt.getZ() )
1280  );
1281 }
1282 
1283 inline const Point3 sqrtPerElem( const Point3 & pnt )
1284 {
1285  return Point3(
1286  sqrtf( pnt.getX() ),
1287  sqrtf( pnt.getY() ),
1288  sqrtf( pnt.getZ() )
1289  );
1290 }
1291 
1292 inline const Point3 rsqrtPerElem( const Point3 & pnt )
1293 {
1294  return Point3(
1295  ( 1.0f / sqrtf( pnt.getX() ) ),
1296  ( 1.0f / sqrtf( pnt.getY() ) ),
1297  ( 1.0f / sqrtf( pnt.getZ() ) )
1298  );
1299 }
1300 
1301 inline const Point3 absPerElem( const Point3 & pnt )
1302 {
1303  return Point3(
1304  fabsf( pnt.getX() ),
1305  fabsf( pnt.getY() ),
1306  fabsf( pnt.getZ() )
1307  );
1308 }
1309 
1310 inline const Point3 copySignPerElem( const Point3 & pnt0, const Point3 & pnt1 )
1311 {
1312  return Point3(
1313  ( pnt1.getX() < 0.0f )? -fabsf( pnt0.getX() ) : fabsf( pnt0.getX() ),
1314  ( pnt1.getY() < 0.0f )? -fabsf( pnt0.getY() ) : fabsf( pnt0.getY() ),
1315  ( pnt1.getZ() < 0.0f )? -fabsf( pnt0.getZ() ) : fabsf( pnt0.getZ() )
1316  );
1317 }
1318 
1319 inline const Point3 maxPerElem( const Point3 & pnt0, const Point3 & pnt1 )
1320 {
1321  return Point3(
1322  (pnt0.getX() > pnt1.getX())? pnt0.getX() : pnt1.getX(),
1323  (pnt0.getY() > pnt1.getY())? pnt0.getY() : pnt1.getY(),
1324  (pnt0.getZ() > pnt1.getZ())? pnt0.getZ() : pnt1.getZ()
1325  );
1326 }
1327 
1328 inline float maxElem( const Point3 & pnt )
1329 {
1330  float result;
1331  result = (pnt.getX() > pnt.getY())? pnt.getX() : pnt.getY();
1332  result = (pnt.getZ() > result)? pnt.getZ() : result;
1333  return result;
1334 }
1335 
1336 inline const Point3 minPerElem( const Point3 & pnt0, const Point3 & pnt1 )
1337 {
1338  return Point3(
1339  (pnt0.getX() < pnt1.getX())? pnt0.getX() : pnt1.getX(),
1340  (pnt0.getY() < pnt1.getY())? pnt0.getY() : pnt1.getY(),
1341  (pnt0.getZ() < pnt1.getZ())? pnt0.getZ() : pnt1.getZ()
1342  );
1343 }
1344 
1345 inline float minElem( const Point3 & pnt )
1346 {
1347  float result;
1348  result = (pnt.getX() < pnt.getY())? pnt.getX() : pnt.getY();
1349  result = (pnt.getZ() < result)? pnt.getZ() : result;
1350  return result;
1351 }
1352 
1353 inline float sum( const Point3 & pnt )
1354 {
1355  float result;
1356  result = ( pnt.getX() + pnt.getY() );
1357  result = ( result + pnt.getZ() );
1358  return result;
1359 }
1360 
1361 inline const Point3 scale( const Point3 & pnt, float scaleVal )
1362 {
1363  return mulPerElem( pnt, Point3( scaleVal ) );
1364 }
1365 
1366 inline const Point3 scale( const Point3 & pnt, const Vector3 & scaleVec )
1367 {
1368  return mulPerElem( pnt, Point3( scaleVec ) );
1369 }
1370 
1371 inline float projection( const Point3 & pnt, const Vector3 & unitVec )
1372 {
1373  float result;
1374  result = ( pnt.getX() * unitVec.getX() );
1375  result = ( result + ( pnt.getY() * unitVec.getY() ) );
1376  result = ( result + ( pnt.getZ() * unitVec.getZ() ) );
1377  return result;
1378 }
1379 
1380 inline float distSqrFromOrigin( const Point3 & pnt )
1381 {
1382  return lengthSqr( Vector3( pnt ) );
1383 }
1384 
1385 inline float distFromOrigin( const Point3 & pnt )
1386 {
1387  return length( Vector3( pnt ) );
1388 }
1389 
1390 inline float distSqr( const Point3 & pnt0, const Point3 & pnt1 )
1391 {
1392  return lengthSqr( ( pnt1 - pnt0 ) );
1393 }
1394 
1395 inline float dist( const Point3 & pnt0, const Point3 & pnt1 )
1396 {
1397  return length( ( pnt1 - pnt0 ) );
1398 }
1399 
1400 inline const Point3 select( const Point3 & pnt0, const Point3 & pnt1, bool select1 )
1401 {
1402  return Point3(
1403  ( select1 )? pnt1.getX() : pnt0.getX(),
1404  ( select1 )? pnt1.getY() : pnt0.getY(),
1405  ( select1 )? pnt1.getZ() : pnt0.getZ()
1406  );
1407 }
1408 
1409 #ifdef _VECTORMATH_DEBUG
1410 
1411 inline void print( const Point3 & pnt )
1412 {
1413  printf( "( %f %f %f )\n", pnt.getX(), pnt.getY(), pnt.getZ() );
1414 }
1415 
1416 inline void print( const Point3 & pnt, const char * name )
1417 {
1418  printf( "%s: ( %f %f %f )\n", name, pnt.getX(), pnt.getY(), pnt.getZ() );
1419 }
1420 
1421 #endif
1422 
1423 } // namespace Aos
1424 } // namespace Vectormath
1425 
1426 #endif
const Vector4 operator*(float scalar) const
Definition: neon/vec_aos.h:796
const Quat normalize(const Quat &quat)
float & operator[](int idx)
const Vector3 getXYZ() const
Definition: neon/vec_aos.h:706
const Vector3 recipPerElem(const Vector3 &vec)
Definition: neon/vec_aos.h:351
static const Vector4 yAxis()
Definition: neon/vec_aos.h:564
float minElem(const Vector3 &vec)
Definition: neon/vec_aos.h:422
void loadHalfFloats(Vector3 &vec, const unsigned short *hfptr)
Definition: neon/vec_aos.h:112
Vector4 & setXYZ(const Vector3 &vec)
Definition: neon/vec_aos.h:698
Vector4 & operator+=(const Vector4 &vec)
Definition: neon/vec_aos.h:806
static const Vector3 xAxis()
Definition: neon/vec_aos.h:64
static const Vector3 zAxis()
Definition: neon/vec_aos.h:74
void storeHalfFloats(const Vector3 &vec, unsigned short *hfptr)
Definition: neon/vec_aos.h:145
float dist(const Point3 &pnt0, const Point3 &pnt1)
const Vector3 minPerElem(const Vector3 &vec0, const Vector3 &vec1)
Definition: neon/vec_aos.h:413
Point3 & operator=(const Point3 &pnt)
Point3 & setElem(int idx, float value)
static const Vector4 xAxis()
Definition: neon/vec_aos.h:559
Vector3 & operator=(const Vector3 &vec)
Definition: neon/vec_aos.h:188
Point3 & operator-=(const Vector3 &vec)
float distFromOrigin(const Point3 &pnt)
const Vector4 operator-() const
Definition: neon/vec_aos.h:840
Vector3 & operator/=(float scalar)
Definition: neon/vec_aos.h:313
const Vector3 sqrtPerElem(const Vector3 &vec)
Definition: neon/vec_aos.h:360
Vector3 & setY(float y)
Definition: neon/vec_aos.h:207
static const Vector3 yAxis()
Definition: neon/vec_aos.h:69
Vector4 & setW(float w)
Definition: neon/vec_aos.h:744
Vector3 & operator-=(const Vector3 &vec)
Definition: neon/vec_aos.h:292
static const Vector4 wAxis()
Definition: neon/vec_aos.h:574
Vector4 & setZ(float z)
Definition: neon/vec_aos.h:733
const Vector3 maxPerElem(const Vector3 &vec0, const Vector3 &vec1)
Definition: neon/vec_aos.h:396
float lengthSqr(const Vector3 &vec)
Definition: neon/vec_aos.h:447
Vector3 & setZ(float z)
Definition: neon/vec_aos.h:218
float distSqrFromOrigin(const Point3 &pnt)
const Point3 operator+(const Vector3 &vec) const
float & operator[](int idx)
Definition: neon/vec_aos.h:766
const Point3 scale(const Point3 &pnt, float scaleVal)
const Vector3 operator-(const Point3 &pnt) const
float projection(const Point3 &pnt, const Vector3 &unitVec)
Vector3 & setX(float x)
Definition: neon/vec_aos.h:196
const Vector3 copySignPerElem(const Vector3 &vec0, const Vector3 &vec1)
Definition: neon/vec_aos.h:387
const Vector3 operator-() const
Definition: neon/vec_aos.h:319
const Vector3 operator+(const Vector3 &vec) const
Definition: neon/vec_aos.h:250
Vector3 & setElem(int idx, float value)
Definition: neon/vec_aos.h:229
const Vector3 operator/(float scalar) const
Definition: neon/vec_aos.h:304
Point3 & operator+=(const Vector3 &vec)
void loadXYZW(Quat &quat, const float *fptr)
const Vector4 operator+(const Vector4 &vec) const
Definition: neon/vec_aos.h:776
const Vector3 rsqrtPerElem(const Vector3 &vec)
Definition: neon/vec_aos.h:369
float distSqr(const Point3 &pnt0, const Point3 &pnt1)
float getElem(int idx) const
Definition: neon/vec_aos.h:235
#define _VECTORMATH_SLERP_TOL
void storeXYZW(const Quat &quat, float *fptr)
const Quat lerp(float t, const Quat &quat0, const Quat &quat1)
Definition: neon/quat_aos.h:73
const Matrix3 select(const Matrix3 &mat0, const Matrix3 &mat1, bool select1)
Definition: neon/mat_aos.h:409
Point3 & setZ(float z)
Vector4 & setX(float x)
Definition: neon/vec_aos.h:711
const Vector4 operator/(float scalar) const
Definition: neon/vec_aos.h:824
Vector3 & operator*=(float scalar)
Definition: neon/vec_aos.h:298
float getElem(int idx) const
Definition: neon/vec_aos.h:761
Vector3 & operator+=(const Vector3 &vec)
Definition: neon/vec_aos.h:286
float getElem(int idx) const
float maxElem(const Vector3 &vec)
Definition: neon/vec_aos.h:405
void storeXYZ(const Vector3 &vec, float *fptr)
Definition: neon/vec_aos.h:105
float & operator[](int idx)
Definition: neon/vec_aos.h:240
Point3 & setX(float x)
float sum(const Vector3 &vec)
Definition: neon/vec_aos.h:430
static const Vector4 zAxis()
Definition: neon/vec_aos.h:569
float dot(const Quat &quat0, const Quat &quat1)
const Vector3 cross(const Vector3 &vec0, const Vector3 &vec1)
Definition: neon/vec_aos.h:473
const Matrix3 mulPerElem(const Matrix3 &mat0, const Matrix3 &mat1)
Definition: neon/mat_aos.h:286
Vector4 & operator/=(float scalar)
Definition: neon/vec_aos.h:834
Vector4 & setY(float y)
Definition: neon/vec_aos.h:722
const Vector3 operator*(float scalar) const
Definition: neon/vec_aos.h:277
float length(const Quat &quat)
Vector4 & operator*=(float scalar)
Definition: neon/vec_aos.h:818
const Vector3 divPerElem(const Vector3 &vec0, const Vector3 &vec1)
Definition: neon/vec_aos.h:342
Point3 & setY(float y)
const Matrix3 absPerElem(const Matrix3 &mat)
Definition: neon/mat_aos.h:233
Vector4 & setElem(int idx, float value)
Definition: neon/vec_aos.h:755
const Matrix3 operator*(float scalar, const Matrix3 &mat)
Definition: neon/mat_aos.h:257
Vector4 & operator=(const Vector4 &vec)
Definition: neon/vec_aos.h:689
Vector4 & operator-=(const Vector4 &vec)
Definition: neon/vec_aos.h:812
void loadXYZ(Vector3 &vec, const float *fptr)
Definition: neon/vec_aos.h:100
const Quat slerp(float t, const Quat &unitQuat0, const Quat &unitQuat1)
Definition: neon/quat_aos.h:78