orx  1.14
Portable Game Engine
orxVector.h
Go to the documentation of this file.
1 /* Orx - Portable Game Engine
2  *
3  * Copyright (c) 2008-2022 Orx-Project
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  *
18  * 2. Altered source versions must be plainly marked as such, and must not be
19  * misrepresented as being the original software.
20  *
21  * 3. This notice may not be removed or altered from any source
22  * distribution.
23  */
24 
43 #ifndef _orxVECTOR_H_
44 #define _orxVECTOR_H_
45 
46 #include "orxInclude.h"
47 
48 #include "debug/orxDebug.h"
49 #include "memory/orxMemory.h"
50 #include "math/orxMath.h"
51 
52 
53 #ifdef __orxGCC__
54 
55  #pragma GCC diagnostic push
56  #pragma GCC diagnostic ignored "-Wpragmas"
57  #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
58 
59 #endif /* __orxGCC__ */
60 
61 
64 typedef struct __orxVECTOR_t
65 {
67  union
68  {
69  orxFLOAT fX;
70  orxFLOAT fRho;
71  orxFLOAT fR;
72  orxFLOAT fH;
73  };
74 
75  union
76  {
77  orxFLOAT fY;
78  orxFLOAT fTheta;
79  orxFLOAT fG;
80  orxFLOAT fS;
81  };
82 
83  union
84  {
85  orxFLOAT fZ;
86  orxFLOAT fPhi;
87  orxFLOAT fB;
88  orxFLOAT fL;
89  orxFLOAT fV;
90  };
91 
92 } orxVECTOR;
93 
94 
95 /* *** Vector inlined functions *** */
96 
97 
105 static orxINLINE orxVECTOR * orxVector_Set(orxVECTOR *_pvVec, orxFLOAT _fX, orxFLOAT _fY, orxFLOAT _fZ)
106 {
107  /* Checks */
108  orxASSERT(_pvVec != orxNULL);
109 
110  /* Stores values */
111  _pvVec->fX = _fX;
112  _pvVec->fY = _fY;
113  _pvVec->fZ = _fZ;
114 
115  /* Done ! */
116  return _pvVec;
117 }
118 
124 static orxINLINE orxVECTOR * orxVector_SetAll(orxVECTOR *_pvVec, orxFLOAT _fValue)
125 {
126  /* Done ! */
127  return(orxVector_Set(_pvVec, _fValue, _fValue, _fValue));
128 }
129 
135 static orxINLINE orxVECTOR * orxVector_Copy(orxVECTOR *_pvDst, const orxVECTOR *_pvSrc)
136 {
137  /* Checks */
138  orxASSERT(_pvDst != orxNULL);
139  orxASSERT(_pvSrc != orxNULL);
140 
141  /* Copies it */
142  orxMemory_Copy(_pvDst, _pvSrc, sizeof(orxVECTOR));
143 
144  /* Done! */
145  return _pvDst;
146 }
147 
154 static orxINLINE orxVECTOR * orxVector_Add(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
155 {
156  /* Checks */
157  orxASSERT(_pvRes != orxNULL);
158  orxASSERT(_pvOp1 != orxNULL);
159  orxASSERT(_pvOp2 != orxNULL);
160 
161  /* Adds all */
162  _pvRes->fX = _pvOp1->fX + _pvOp2->fX;
163  _pvRes->fY = _pvOp1->fY + _pvOp2->fY;
164  _pvRes->fZ = _pvOp1->fZ + _pvOp2->fZ;
165 
166  /* Done! */
167  return _pvRes;
168 }
169 
176 static orxINLINE orxVECTOR * orxVector_Sub(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
177 {
178  /* Checks */
179  orxASSERT(_pvRes != orxNULL);
180  orxASSERT(_pvOp1 != orxNULL);
181  orxASSERT(_pvOp2 != orxNULL);
182 
183  /* Adds all */
184  _pvRes->fX = _pvOp1->fX - _pvOp2->fX;
185  _pvRes->fY = _pvOp1->fY - _pvOp2->fY;
186  _pvRes->fZ = _pvOp1->fZ - _pvOp2->fZ;
187 
188  /* Done! */
189  return _pvRes;
190 }
191 
198 static orxINLINE orxVECTOR * orxVector_Mulf(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, orxFLOAT _fOp2)
199 {
200  /* Checks */
201  orxASSERT(_pvRes != orxNULL);
202  orxASSERT(_pvOp1 != orxNULL);
203 
204  /* Muls all */
205  _pvRes->fX = _pvOp1->fX * _fOp2;
206  _pvRes->fY = _pvOp1->fY * _fOp2;
207  _pvRes->fZ = _pvOp1->fZ * _fOp2;
208 
209  /* Done! */
210  return _pvRes;
211 }
212 
219 static orxINLINE orxVECTOR * orxVector_Mul(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
220 {
221  /* Checks */
222  orxASSERT(_pvRes != orxNULL);
223  orxASSERT(_pvOp1 != orxNULL);
224  orxASSERT(_pvOp2 != orxNULL);
225 
226  /* Muls all */
227  _pvRes->fX = _pvOp1->fX * _pvOp2->fX;
228  _pvRes->fY = _pvOp1->fY * _pvOp2->fY;
229  _pvRes->fZ = _pvOp1->fZ * _pvOp2->fZ;
230 
231  /* Done! */
232  return _pvRes;
233 }
234 
241 static orxINLINE orxVECTOR * orxVector_Divf(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, orxFLOAT _fOp2)
242 {
243  orxFLOAT fRecCoef;
244 
245  /* Checks */
246  orxASSERT(_pvRes != orxNULL);
247  orxASSERT(_pvOp1 != orxNULL);
248  orxASSERT(_fOp2 != orxFLOAT_0);
249 
250  /* Gets reciprocal coef */
251  fRecCoef = orxFLOAT_1 / _fOp2;
252 
253  /* Muls all */
254  _pvRes->fX = _pvOp1->fX * fRecCoef;
255  _pvRes->fY = _pvOp1->fY * fRecCoef;
256  _pvRes->fZ = _pvOp1->fZ * fRecCoef;
257 
258  /* Done! */
259  return _pvRes;
260 }
261 
268 static orxINLINE orxVECTOR * orxVector_Div(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
269 {
270  /* Checks */
271  orxASSERT(_pvRes != orxNULL);
272  orxASSERT(_pvOp1 != orxNULL);
273  orxASSERT(_pvOp2 != orxNULL);
274 
275  /* Divs all */
276  _pvRes->fX = _pvOp1->fX / _pvOp2->fX;
277  _pvRes->fY = _pvOp1->fY / _pvOp2->fY;
278  _pvRes->fZ = _pvOp1->fZ / _pvOp2->fZ;
279 
280  /* Done! */
281  return _pvRes;
282 }
283 
291 static orxINLINE orxVECTOR * orxVector_Lerp(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2, orxFLOAT _fOp)
292 {
293  /* Checks */
294  orxASSERT(_pvRes != orxNULL);
295  orxASSERT(_pvOp1 != orxNULL);
296  orxASSERT(_pvOp2 != orxNULL);
297 
298  /* Lerps all*/
299  _pvRes->fX = orxLERP(_pvOp1->fX, _pvOp2->fX, _fOp);
300  _pvRes->fY = orxLERP(_pvOp1->fY, _pvOp2->fY, _fOp);
301  _pvRes->fZ = orxLERP(_pvOp1->fZ, _pvOp2->fZ, _fOp);
302 
303  /* Done! */
304  return _pvRes;
305 }
306 
313 static orxINLINE orxVECTOR * orxVector_Min(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
314 {
315  /* Checks */
316  orxASSERT(_pvRes != orxNULL);
317  orxASSERT(_pvOp1 != orxNULL);
318  orxASSERT(_pvOp2 != orxNULL);
319 
320  /* Gets all mins */
321  _pvRes->fX = orxMIN(_pvOp1->fX, _pvOp2->fX);
322  _pvRes->fY = orxMIN(_pvOp1->fY, _pvOp2->fY);
323  _pvRes->fZ = orxMIN(_pvOp1->fZ, _pvOp2->fZ);
324 
325  /* Done! */
326  return _pvRes;
327 }
328 
335 static orxINLINE orxVECTOR * orxVector_Max(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
336 {
337  /* Checks */
338  orxASSERT(_pvRes != orxNULL);
339  orxASSERT(_pvOp1 != orxNULL);
340  orxASSERT(_pvOp2 != orxNULL);
341 
342  /* Gets all maxs */
343  _pvRes->fX = orxMAX(_pvOp1->fX, _pvOp2->fX);
344  _pvRes->fY = orxMAX(_pvOp1->fY, _pvOp2->fY);
345  _pvRes->fZ = orxMAX(_pvOp1->fZ, _pvOp2->fZ);
346 
347  /* Done! */
348  return _pvRes;
349 }
350 
358 static orxINLINE orxVECTOR * orxVector_Clamp(orxVECTOR *_pvRes, const orxVECTOR *_pvOp, const orxVECTOR *_pvMin, const orxVECTOR *_pvMax)
359 {
360  /* Checks */
361  orxASSERT(_pvRes != orxNULL);
362  orxASSERT(_pvOp != orxNULL);
363  orxASSERT(_pvMin != orxNULL);
364  orxASSERT(_pvMax != orxNULL);
365 
366  /* Gets all clamped values */
367  _pvRes->fX = orxCLAMP(_pvOp->fX, _pvMin->fX, _pvMax->fX);
368  _pvRes->fY = orxCLAMP(_pvOp->fY, _pvMin->fY, _pvMax->fY);
369  _pvRes->fZ = orxCLAMP(_pvOp->fZ, _pvMin->fZ, _pvMax->fZ);
370 
371  /* Done! */
372  return _pvRes;
373 }
374 
380 static orxINLINE orxVECTOR * orxVector_Abs(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
381 {
382  /* Checks */
383  orxASSERT(_pvRes != orxNULL);
384  orxASSERT(_pvOp != orxNULL);
385 
386  /* Negates all */
387  _pvRes->fX = orxMath_Abs(_pvOp->fX);
388  _pvRes->fY = orxMath_Abs(_pvOp->fY);
389  _pvRes->fZ = orxMath_Abs(_pvOp->fZ);
390 
391  /* Done! */
392  return _pvRes;
393 }
394 
400 static orxINLINE orxVECTOR * orxVector_Neg(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
401 {
402  /* Checks */
403  orxASSERT(_pvRes != orxNULL);
404  orxASSERT(_pvOp != orxNULL);
405 
406  /* Negates all */
407  _pvRes->fX = -(_pvOp->fX);
408  _pvRes->fY = -(_pvOp->fY);
409  _pvRes->fZ = -(_pvOp->fZ);
410 
411  /* Done! */
412  return _pvRes;
413 }
414 
420 static orxINLINE orxVECTOR * orxVector_Rec(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
421 {
422  /* Checks */
423  orxASSERT(_pvRes != orxNULL);
424  orxASSERT(_pvOp != orxNULL);
425 
426  /* Reverts all */
427  _pvRes->fX = orxFLOAT_1 / _pvOp->fX;
428  _pvRes->fY = orxFLOAT_1 / _pvOp->fY;
429  _pvRes->fZ = orxFLOAT_1 / _pvOp->fZ;
430 
431  /* Done! */
432  return _pvRes;
433 }
434 
440 static orxINLINE orxVECTOR * orxVector_Floor(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
441 {
442  /* Checks */
443  orxASSERT(_pvRes != orxNULL);
444  orxASSERT(_pvOp != orxNULL);
445 
446  /* Reverts all */
447  _pvRes->fX = orxMath_Floor(_pvOp->fX);
448  _pvRes->fY = orxMath_Floor(_pvOp->fY);
449  _pvRes->fZ = orxMath_Floor(_pvOp->fZ);
450 
451  /* Done! */
452  return _pvRes;
453 }
454 
460 static orxINLINE orxVECTOR * orxVector_Round(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
461 {
462  /* Checks */
463  orxASSERT(_pvRes != orxNULL);
464  orxASSERT(_pvOp != orxNULL);
465 
466  /* Reverts all */
467  _pvRes->fX = orxMath_Round(_pvOp->fX);
468  _pvRes->fY = orxMath_Round(_pvOp->fY);
469  _pvRes->fZ = orxMath_Round(_pvOp->fZ);
470 
471  /* Done! */
472  return _pvRes;
473 }
474 
479 static orxINLINE orxFLOAT orxVector_GetSquareSize(const orxVECTOR *_pvOp)
480 {
481  orxFLOAT fResult;
482 
483  /* Checks */
484  orxASSERT(_pvOp != orxNULL);
485 
486  /* Updates result */
487  fResult = (_pvOp->fX * _pvOp->fX) + (_pvOp->fY * _pvOp->fY) + (_pvOp->fZ * _pvOp->fZ);
488 
489  /* Done! */
490  return fResult;
491 }
492 
497 static orxINLINE orxFLOAT orxVector_GetSize(const orxVECTOR *_pvOp)
498 {
499  orxFLOAT fResult;
500 
501  /* Checks */
502  orxASSERT(_pvOp != orxNULL);
503 
504  /* Updates result */
505  fResult = orxMath_Sqrt((_pvOp->fX * _pvOp->fX) + (_pvOp->fY * _pvOp->fY) + (_pvOp->fZ * _pvOp->fZ));
506 
507  /* Done! */
508  return fResult;
509 }
510 
516 static orxINLINE orxFLOAT orxVector_GetSquareDistance(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
517 {
518  orxVECTOR vTemp;
519  orxFLOAT fResult;
520 
521  /* Checks */
522  orxASSERT(_pvOp1 != orxNULL);
523  orxASSERT(_pvOp2 != orxNULL);
524 
525  /* Gets distance vector */
526  orxVector_Sub(&vTemp, _pvOp2, _pvOp1);
527 
528  /* Updates result */
529  fResult = orxVector_GetSquareSize(&vTemp);
530 
531  /* Done! */
532  return fResult;
533 }
534 
540 static orxINLINE orxFLOAT orxVector_GetDistance(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
541 {
542  orxVECTOR vTemp;
543  orxFLOAT fResult;
544 
545  /* Checks */
546  orxASSERT(_pvOp1 != orxNULL);
547  orxASSERT(_pvOp2 != orxNULL);
548 
549  /* Gets distance vector */
550  orxVector_Sub(&vTemp, _pvOp2, _pvOp1);
551 
552  /* Updates result */
553  fResult = orxVector_GetSize(&vTemp);
554 
555  /* Done! */
556  return fResult;
557 }
558 
564 static orxINLINE orxVECTOR * orxVector_Normalize(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
565 {
566  orxFLOAT fOp;
567 
568  /* Checks */
569  orxASSERT(_pvRes != orxNULL);
570  orxASSERT(_pvOp != orxNULL);
571 
572  /* Gets squared size */
573  fOp = (_pvOp->fX * _pvOp->fX) + (_pvOp->fY * _pvOp->fY) + (_pvOp->fZ * _pvOp->fZ);
574 
575  /* Gets reciprocal size */
577 
578  /* Updates result */
579  _pvRes->fX = fOp * _pvOp->fX;
580  _pvRes->fY = fOp * _pvOp->fY;
581  _pvRes->fZ = fOp * _pvOp->fZ;
582 
583  /* Done! */
584  return _pvRes;
585 }
586 
593 static orxINLINE orxVECTOR * orxVector_2DRotate(orxVECTOR *_pvRes, const orxVECTOR *_pvOp, orxFLOAT _fAngle)
594 {
595  /* Checks */
596  orxASSERT(_pvRes != orxNULL);
597  orxASSERT(_pvOp != orxNULL);
598 
599  /* 0? */
600  if(_fAngle == orxFLOAT_0)
601  {
602  /* Updates result */
603  orxVector_Copy(_pvRes, _pvOp);
604  }
605  /* PI/2? */
606  if(_fAngle == orxMATH_KF_PI_BY_2)
607  {
608  /* Updates result */
609  orxVector_Set(_pvRes, -_pvOp->fY, _pvOp->fX, _pvOp->fZ);
610  }
611  /* -PI/2? */
612  else if(_fAngle == -orxMATH_KF_PI_BY_2)
613  {
614  /* Updates result */
615  orxVector_Set(_pvRes, _pvOp->fY, -_pvOp->fX, _pvOp->fZ);
616  }
617  else if(_fAngle == orxMATH_KF_PI)
618  {
619  /* Updates result */
620  orxVector_Set(_pvRes, -_pvOp->fX, -_pvOp->fY, _pvOp->fZ);
621  }
622  /* Any other angle */
623  else
624  {
625  orxFLOAT fSin, fCos;
626 
627  /* Gets cos & sin of angle */
628  fCos = orxMath_Cos(_fAngle);
629  fSin = orxMath_Sin(_fAngle);
630 
631  /* Updates result */
632  orxVector_Set(_pvRes, (fCos * _pvOp->fX) - (fSin * _pvOp->fY), (fSin * _pvOp->fX) + (fCos * _pvOp->fY), _pvOp->fZ);
633  }
634 
635  /* Done! */
636  return _pvRes;
637 }
638 
643 static orxINLINE orxBOOL orxVector_IsNull(const orxVECTOR *_pvOp)
644 {
645  orxBOOL bResult;
646 
647  /* Checks */
648  orxASSERT(_pvOp != orxNULL);
649 
650  /* Updates result */
651  bResult = ((_pvOp->fX == orxFLOAT_0) && (_pvOp->fY == orxFLOAT_0) && (_pvOp->fZ == orxFLOAT_0)) ? orxTRUE : orxFALSE;
652 
653  /* Done! */
654  return bResult;
655 }
656 
662 static orxINLINE orxBOOL orxVector_AreEqual(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
663 {
664  orxBOOL bResult;
665 
666  /* Checks */
667  orxASSERT(_pvOp1 != orxNULL);
668  orxASSERT(_pvOp2 != orxNULL);
669 
670  /* Updates result */
671  bResult = ((_pvOp1->fX == _pvOp2->fX) && (_pvOp1->fY == _pvOp2->fY) && (_pvOp1->fZ == _pvOp2->fZ)) ? orxTRUE : orxFALSE;
672 
673  /* Done! */
674  return bResult;
675 }
676 
682 static orxINLINE orxVECTOR * orxVector_FromCartesianToSpherical(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
683 {
684  /* Checks */
685  orxASSERT(_pvRes != orxNULL);
686  orxASSERT(_pvOp != orxNULL);
687 
688  /* Is operand vector null? */
689  if((_pvOp->fX == orxFLOAT_0)
690  && (_pvOp->fY == orxFLOAT_0)
691  && (_pvOp->fZ == orxFLOAT_0))
692  {
693  /* Updates result vector */
694  _pvRes->fRho = _pvRes->fTheta = _pvRes->fPhi = orxFLOAT_0;
695  }
696  else
697  {
698  orxFLOAT fRho, fTheta, fPhi;
699 
700  /* Z = 0? */
701  if(_pvOp->fZ == orxFLOAT_0)
702  {
703  /* X = 0? */
704  if(_pvOp->fX == orxFLOAT_0)
705  {
706  /* Gets absolute value */
707  fRho = orxMath_Abs(_pvOp->fY);
708  }
709  /* X != 0 and Y = 0? */
710  else if(_pvOp->fY == orxFLOAT_0)
711  {
712  /* Gets absolute value */
713  fRho = orxMath_Abs(_pvOp->fX);
714  }
715  /* X != 0 and Y != 0 */
716  else
717  {
718  /* Computes rho */
719  fRho = orxMath_Sqrt((_pvOp->fX * _pvOp->fX) + (_pvOp->fY * _pvOp->fY));
720  }
721 
722  /* Sets phi */
723  fPhi = orxFLOAT_0;
724  }
725  else
726  {
727  /* X = 0 and Y = 0? */
728  if((_pvOp->fX == orxFLOAT_0) && (_pvOp->fY == orxFLOAT_0))
729  {
730  /* Z < 0? */
731  if(_pvOp->fZ < orxFLOAT_0)
732  {
733  /* Gets absolute value */
734  fRho = orxMath_Abs(_pvOp->fZ);
735 
736  /* Sets phi */
737  fPhi = orxMATH_KF_PI_BY_2;
738  }
739  else
740  {
741  /* Sets rho */
742  fRho = _pvOp->fZ;
743 
744  /* Sets phi */
745  fPhi = -orxMATH_KF_PI_BY_2;
746  }
747  }
748  else
749  {
750  /* Computes rho */
751  fRho = orxMath_Sqrt(orxVector_GetSquareSize(_pvOp));
752 
753  /* Computes phi */
754  fPhi = orxMath_ACos(_pvOp->fZ / fRho) - orxMATH_KF_PI_BY_2;
755  }
756  }
757 
758  /* Computes theta */
759  fTheta = orxMath_ATan(_pvOp->fY, _pvOp->fX);
760 
761  /* Updates result */
762  _pvRes->fRho = fRho;
763  _pvRes->fTheta = fTheta;
764  _pvRes->fPhi = fPhi;
765  }
766 
767  /* Done! */
768  return _pvRes;
769 }
770 
776 static orxINLINE orxVECTOR * orxVector_FromSphericalToCartesian(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
777 {
778  orxFLOAT fSinPhi, fCosPhi, fSinTheta, fCosTheta, fRho;
779 
780  /* Checks */
781  orxASSERT(_pvRes != orxNULL);
782  orxASSERT(_pvOp != orxNULL);
783 
784  /* Stores rho */
785  fRho = _pvOp->fRho;
786 
787  /* Gets sine & cosine */
788  fSinTheta = orxMath_Sin(_pvOp->fTheta);
789  fCosTheta = orxMath_Cos(_pvOp->fTheta);
790  fSinPhi = orxMath_Sin(_pvOp->fPhi + orxMATH_KF_PI_BY_2);
791  fCosPhi = orxMath_Cos(_pvOp->fPhi + orxMATH_KF_PI_BY_2);
792  if(orxMath_Abs(fSinTheta) < orxMATH_KF_EPSILON)
793  {
794  fSinTheta = orxFLOAT_0;
795  }
796  if(orxMath_Abs(fCosTheta) < orxMATH_KF_EPSILON)
797  {
798  fCosTheta = orxFLOAT_0;
799  }
800  if(orxMath_Abs(fSinPhi) < orxMATH_KF_EPSILON)
801  {
802  fSinPhi = orxFLOAT_0;
803  }
804  if(orxMath_Abs(fCosPhi) < orxMATH_KF_EPSILON)
805  {
806  fCosPhi = orxFLOAT_0;
807  }
808 
809  /* Updates result */
810  _pvRes->fX = fRho * fCosTheta * fSinPhi;
811  _pvRes->fY = fRho * fSinTheta * fSinPhi;
812  _pvRes->fZ = fRho * fCosPhi;
813 
814  /* Done! */
815  return _pvRes;
816 }
817 
823 static orxINLINE orxFLOAT orxVector_Dot(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
824 {
825  orxFLOAT fResult;
826 
827  /* Checks */
828  orxASSERT(_pvOp1 != orxNULL);
829  orxASSERT(_pvOp2 != orxNULL);
830 
831  /* Updates result */
832  fResult = (_pvOp1->fX * _pvOp2->fX) + (_pvOp1->fY * _pvOp2->fY) + (_pvOp1->fZ * _pvOp2->fZ);
833 
834  /* Done! */
835  return fResult;
836 }
837 
843 static orxINLINE orxFLOAT orxVector_2DDot(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
844 {
845  orxFLOAT fResult;
846 
847  /* Checks */
848  orxASSERT(_pvOp1 != orxNULL);
849  orxASSERT(_pvOp2 != orxNULL);
850 
851  /* Updates result */
852  fResult = (_pvOp1->fX * _pvOp2->fX) + (_pvOp1->fY * _pvOp2->fY);
853 
854  /* Done! */
855  return fResult;
856 }
857 
864 static orxINLINE orxVECTOR * orxVector_Cross(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
865 {
866  orxFLOAT fTemp1, fTemp2;
867 
868  /* Checks */
869  orxASSERT(_pvRes != orxNULL);
870  orxASSERT(_pvOp1 != orxNULL);
871  orxASSERT(_pvOp2 != orxNULL);
872 
873  /* Computes cross product */
874  fTemp1 = (_pvOp1->fY * _pvOp2->fZ) - (_pvOp1->fZ * _pvOp2->fY);
875  fTemp2 = (_pvOp1->fZ * _pvOp2->fX) - (_pvOp1->fX * _pvOp2->fZ);
876  _pvRes->fZ = (_pvOp1->fX * _pvOp2->fY) - (_pvOp1->fY * _pvOp2->fX);
877  _pvRes->fY = fTemp2;
878  _pvRes->fX = fTemp1;
879 
880  /* Done! */
881  return _pvRes;
882 }
883 
884 
885 /* *** Vector functions *** */
886 
896 extern orxDLLAPI orxVECTOR *orxFASTCALL orxVector_Bezier(orxVECTOR *_pvRes, const orxVECTOR *_pvPoint1, const orxVECTOR *_pvPoint2, const orxVECTOR *_pvPoint3, const orxVECTOR *_pvPoint4, orxFLOAT _fT);
897 
907 extern orxDLLAPI orxVECTOR *orxFASTCALL orxVector_CatmullRom(orxVECTOR *_pvRes, const orxVECTOR *_pvPoint1, const orxVECTOR *_pvPoint2, const orxVECTOR *_pvPoint3, const orxVECTOR *_pvPoint4, orxFLOAT _fT);
908 
909 
910 /* *** Vector constants *** */
911 
912 extern orxDLLAPI const orxVECTOR orxVECTOR_X;
913 extern orxDLLAPI const orxVECTOR orxVECTOR_Y;
914 extern orxDLLAPI const orxVECTOR orxVECTOR_Z;
916 extern orxDLLAPI const orxVECTOR orxVECTOR_0;
917 extern orxDLLAPI const orxVECTOR orxVECTOR_1;
919 #define orxCOLOR_DECLARE(NAME, R, G, B) extern orxDLLAPI const orxVECTOR orxVECTOR_##NAME;
920 
921 #include "display/orxColorList.inc"
922 
923 #undef orxCOLOR_DECLARE
924 
925 #ifdef __orxGCC__
926 
927  #pragma GCC diagnostic pop
928 
929 #endif /* __orxGCC__ */
930 
931 #endif /* _orxVECTOR_H_ */
932 
#define orxLERP(A, B, T)
Definition: orxMath.h:66
static orxINLINE orxFLOAT orxVector_GetSize(const orxVECTOR *_pvOp)
Definition: orxVector.h:497
static orxINLINE orxVECTOR * orxVector_Div(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:268
orxFLOAT fTheta
Definition: orxVector.h:78
orxFLOAT fB
Definition: orxVector.h:87
static orxINLINE orxVECTOR * orxVector_Mulf(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, orxFLOAT _fOp2)
Definition: orxVector.h:198
static orxINLINE orxFLOAT orxMath_Round(orxFLOAT _fOp)
Definition: orxMath.h:545
static orxINLINE orxBOOL orxVector_AreEqual(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:662
static orxINLINE orxFLOAT orxVector_GetSquareDistance(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:516
static orxINLINE orxVECTOR * orxVector_Floor(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:440
static orxINLINE orxFLOAT orxVector_Dot(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:823
static orxINLINE orxVECTOR * orxVector_Divf(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, orxFLOAT _fOp2)
Definition: orxVector.h:241
#define orxTRUE
Definition: orxType.h:198
static const orxFLOAT orxFLOAT_1
Definition: orxType.h:203
static orxINLINE orxVECTOR * orxVector_2DRotate(orxVECTOR *_pvRes, const orxVECTOR *_pvOp, orxFLOAT _fAngle)
Definition: orxVector.h:593
static orxINLINE orxVECTOR * orxVector_FromSphericalToCartesian(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:776
#define orxMIN(A, B)
Definition: orxMath.h:74
static orxINLINE orxVECTOR * orxVector_Mul(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:219
orxFLOAT fY
Definition: orxVector.h:77
orxDLLAPI const orxVECTOR orxVECTOR_1
#define orxCLAMP(V, MIN, MAX)
Definition: orxMath.h:89
static orxINLINE orxFLOAT orxMath_Sqrt(orxFLOAT _fOp)
Definition: orxMath.h:500
orxDLLAPI const orxVECTOR orxVECTOR_Y
orxDLLAPI orxVECTOR *orxFASTCALL orxVector_CatmullRom(orxVECTOR *_pvRes, const orxVECTOR *_pvPoint1, const orxVECTOR *_pvPoint2, const orxVECTOR *_pvPoint3, const orxVECTOR *_pvPoint4, orxFLOAT _fT)
#define orxFALSE
Definition: orxType.h:197
static orxINLINE orxBOOL orxVector_IsNull(const orxVECTOR *_pvOp)
Definition: orxVector.h:643
static orxINLINE orxFLOAT orxMath_Sin(orxFLOAT _fOp)
Definition: orxMath.h:406
orxFLOAT fPhi
Definition: orxVector.h:86
static orxINLINE orxVECTOR * orxVector_Min(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:313
static orxINLINE orxVECTOR * orxVector_Neg(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:400
orxFLOAT fX
Definition: orxVector.h:69
orxFLOAT fS
Definition: orxVector.h:80
static orxINLINE orxFLOAT orxMath_Floor(orxFLOAT _fOp)
Definition: orxMath.h:515
static orxINLINE orxFLOAT orxVector_GetSquareSize(const orxVECTOR *_pvOp)
Definition: orxVector.h:479
static orxINLINE orxFLOAT orxMath_Abs(orxFLOAT _fOp)
Definition: orxMath.h:601
static orxINLINE orxFLOAT orxVector_2DDot(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:843
orxDLLAPI orxVECTOR *orxFASTCALL orxVector_Bezier(orxVECTOR *_pvRes, const orxVECTOR *_pvPoint1, const orxVECTOR *_pvPoint2, const orxVECTOR *_pvPoint3, const orxVECTOR *_pvPoint4, orxFLOAT _fT)
static orxINLINE orxVECTOR * orxVector_Set(orxVECTOR *_pvVec, orxFLOAT _fX, orxFLOAT _fY, orxFLOAT _fZ)
Definition: orxVector.h:105
static orxINLINE orxVECTOR * orxVector_Lerp(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2, orxFLOAT _fOp)
Definition: orxVector.h:291
orxFLOAT fG
Definition: orxVector.h:79
#define orxMAX(A, B)
Definition: orxMath.h:81
static orxINLINE orxVECTOR * orxVector_Clamp(orxVECTOR *_pvRes, const orxVECTOR *_pvOp, const orxVECTOR *_pvMin, const orxVECTOR *_pvMax)
Definition: orxVector.h:358
static orxINLINE orxFLOAT orxMath_ACos(orxFLOAT _fOp)
Definition: orxMath.h:451
#define orxMATH_KF_PI
Definition: orxMath.h:393
static orxINLINE orxFLOAT orxMath_Cos(orxFLOAT _fOp)
Definition: orxMath.h:421
static orxINLINE orxVECTOR * orxVector_Normalize(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:564
orxFLOAT fR
Definition: orxVector.h:71
static orxINLINE orxVECTOR * orxVector_Add(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:154
#define orxMATH_KF_EPSILON
Definition: orxMath.h:389
orxFLOAT fZ
Definition: orxVector.h:85
#define orxDLLAPI
Definition: orxDecl.h:370
static orxINLINE orxVECTOR * orxVector_FromCartesianToSpherical(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:682
orxDLLAPI const orxVECTOR orxVECTOR_X
orxFLOAT fV
Definition: orxVector.h:89
static orxINLINE orxVECTOR * orxVector_SetAll(orxVECTOR *_pvVec, orxFLOAT _fValue)
Definition: orxVector.h:124
static orxINLINE orxVECTOR * orxVector_Round(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:460
static orxINLINE orxVECTOR * orxVector_Cross(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:864
static const orxFLOAT orxFLOAT_0
Definition: orxType.h:202
#define orxMATH_KF_TINY_EPSILON
Definition: orxMath.h:390
orxDLLAPI const orxVECTOR orxVECTOR_0
static orxINLINE orxFLOAT orxMath_ATan(orxFLOAT _fOp1, orxFLOAT _fOp2)
Definition: orxMath.h:482
static orxINLINE orxVECTOR * orxVector_Sub(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:176
static orxINLINE orxVECTOR * orxVector_Max(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:335
static orxINLINE orxVECTOR * orxVector_Abs(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:380
static orxINLINE void * orxMemory_Copy(void *_pDest, const void *_pSrc, orxU32 _u32Size)
Definition: orxMemory.h:149
orxFLOAT fL
Definition: orxVector.h:88
#define orxMATH_KF_PI_BY_2
Definition: orxMath.h:394
#define orxASSERT(TEST,...)
Definition: orxDebug.h:372
static orxINLINE orxVECTOR * orxVector_Copy(orxVECTOR *_pvDst, const orxVECTOR *_pvSrc)
Definition: orxVector.h:135
static orxINLINE orxFLOAT orxVector_GetDistance(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:540
orxFLOAT fH
Definition: orxVector.h:72
static orxINLINE orxVECTOR * orxVector_Rec(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:420
orxDLLAPI const orxVECTOR orxVECTOR_Z
orxFLOAT fRho
Definition: orxVector.h:70

Generated for orx by doxygen 1.8.11