orx  1.9
Portable Game Engine
orxVector.h
Go to the documentation of this file.
1 /* Orx - Portable Game Engine
2  *
3  * Copyright (c) 2008-2018 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  register 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  orxASSERT(_fOp >= orxFLOAT_0);
298 
299  /* Lerps all*/
300  _pvRes->fX = orxLERP(_pvOp1->fX, _pvOp2->fX, _fOp);
301  _pvRes->fY = orxLERP(_pvOp1->fY, _pvOp2->fY, _fOp);
302  _pvRes->fZ = orxLERP(_pvOp1->fZ, _pvOp2->fZ, _fOp);
303 
304  /* Done! */
305  return _pvRes;
306 }
307 
314 static orxINLINE orxVECTOR * orxVector_Min(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
315 {
316  /* Checks */
317  orxASSERT(_pvRes != orxNULL);
318  orxASSERT(_pvOp1 != orxNULL);
319  orxASSERT(_pvOp2 != orxNULL);
320 
321  /* Gets all mins */
322  _pvRes->fX = orxMIN(_pvOp1->fX, _pvOp2->fX);
323  _pvRes->fY = orxMIN(_pvOp1->fY, _pvOp2->fY);
324  _pvRes->fZ = orxMIN(_pvOp1->fZ, _pvOp2->fZ);
325 
326  /* Done! */
327  return _pvRes;
328 }
329 
336 static orxINLINE orxVECTOR * orxVector_Max(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
337 {
338  /* Checks */
339  orxASSERT(_pvRes != orxNULL);
340  orxASSERT(_pvOp1 != orxNULL);
341  orxASSERT(_pvOp2 != orxNULL);
342 
343  /* Gets all maxs */
344  _pvRes->fX = orxMAX(_pvOp1->fX, _pvOp2->fX);
345  _pvRes->fY = orxMAX(_pvOp1->fY, _pvOp2->fY);
346  _pvRes->fZ = orxMAX(_pvOp1->fZ, _pvOp2->fZ);
347 
348  /* Done! */
349  return _pvRes;
350 }
351 
359 static orxINLINE orxVECTOR * orxVector_Clamp(orxVECTOR *_pvRes, const orxVECTOR *_pvOp, const orxVECTOR *_pvMin, const orxVECTOR *_pvMax)
360 {
361  /* Checks */
362  orxASSERT(_pvRes != orxNULL);
363  orxASSERT(_pvOp != orxNULL);
364  orxASSERT(_pvMin != orxNULL);
365  orxASSERT(_pvMax != orxNULL);
366 
367  /* Gets all clamped values */
368  _pvRes->fX = orxCLAMP(_pvOp->fX, _pvMin->fX, _pvMax->fX);
369  _pvRes->fY = orxCLAMP(_pvOp->fY, _pvMin->fY, _pvMax->fY);
370  _pvRes->fZ = orxCLAMP(_pvOp->fZ, _pvMin->fZ, _pvMax->fZ);
371 
372  /* Done! */
373  return _pvRes;
374 }
375 
381 static orxINLINE orxVECTOR * orxVector_Neg(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
382 {
383  /* Checks */
384  orxASSERT(_pvRes != orxNULL);
385  orxASSERT(_pvOp != orxNULL);
386 
387  /* Negates all */
388  _pvRes->fX = -(_pvOp->fX);
389  _pvRes->fY = -(_pvOp->fY);
390  _pvRes->fZ = -(_pvOp->fZ);
391 
392  /* Done! */
393  return _pvRes;
394 }
395 
401 static orxINLINE orxVECTOR * orxVector_Rec(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
402 {
403  /* Checks */
404  orxASSERT(_pvRes != orxNULL);
405  orxASSERT(_pvOp != orxNULL);
406 
407  /* Reverts all */
408  _pvRes->fX = orxFLOAT_1 / _pvOp->fX;
409  _pvRes->fY = orxFLOAT_1 / _pvOp->fY;
410  _pvRes->fZ = orxFLOAT_1 / _pvOp->fZ;
411 
412  /* Done! */
413  return _pvRes;
414 }
415 
421 static orxINLINE orxVECTOR * orxVector_Floor(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
422 {
423  /* Checks */
424  orxASSERT(_pvRes != orxNULL);
425  orxASSERT(_pvOp != orxNULL);
426 
427  /* Reverts all */
428  _pvRes->fX = orxMath_Floor(_pvOp->fX);
429  _pvRes->fY = orxMath_Floor(_pvOp->fY);
430  _pvRes->fZ = orxMath_Floor(_pvOp->fZ);
431 
432  /* Done! */
433  return _pvRes;
434 }
435 
441 static orxINLINE orxVECTOR * orxVector_Round(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
442 {
443  /* Checks */
444  orxASSERT(_pvRes != orxNULL);
445  orxASSERT(_pvOp != orxNULL);
446 
447  /* Reverts all */
448  _pvRes->fX = orxMath_Round(_pvOp->fX);
449  _pvRes->fY = orxMath_Round(_pvOp->fY);
450  _pvRes->fZ = orxMath_Round(_pvOp->fZ);
451 
452  /* Done! */
453  return _pvRes;
454 }
455 
460 static orxINLINE orxFLOAT orxVector_GetSquareSize(const orxVECTOR *_pvOp)
461 {
462  register orxFLOAT fResult;
463 
464  /* Checks */
465  orxASSERT(_pvOp != orxNULL);
466 
467  /* Updates result */
468  fResult = (_pvOp->fX * _pvOp->fX) + (_pvOp->fY * _pvOp->fY) + (_pvOp->fZ * _pvOp->fZ);
469 
470  /* Done! */
471  return fResult;
472 }
473 
478 static orxINLINE orxFLOAT orxVector_GetSize(const orxVECTOR *_pvOp)
479 {
480  register orxFLOAT fResult;
481 
482  /* Checks */
483  orxASSERT(_pvOp != orxNULL);
484 
485  /* Updates result */
486  fResult = orxMath_Sqrt((_pvOp->fX * _pvOp->fX) + (_pvOp->fY * _pvOp->fY) + (_pvOp->fZ * _pvOp->fZ));
487 
488  /* Done! */
489  return fResult;
490 }
491 
497 static orxINLINE orxFLOAT orxVector_GetSquareDistance(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
498 {
499  orxVECTOR vTemp;
500  register orxFLOAT fResult;
501 
502  /* Checks */
503  orxASSERT(_pvOp1 != orxNULL);
504  orxASSERT(_pvOp2 != orxNULL);
505 
506  /* Gets distance vector */
507  orxVector_Sub(&vTemp, _pvOp2, _pvOp1);
508 
509  /* Updates result */
510  fResult = orxVector_GetSquareSize(&vTemp);
511 
512  /* Done! */
513  return fResult;
514 }
515 
521 static orxINLINE orxFLOAT orxVector_GetDistance(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
522 {
523  orxVECTOR vTemp;
524  register orxFLOAT fResult;
525 
526  /* Checks */
527  orxASSERT(_pvOp1 != orxNULL);
528  orxASSERT(_pvOp2 != orxNULL);
529 
530  /* Gets distance vector */
531  orxVector_Sub(&vTemp, _pvOp2, _pvOp1);
532 
533  /* Updates result */
534  fResult = orxVector_GetSize(&vTemp);
535 
536  /* Done! */
537  return fResult;
538 }
539 
545 static orxINLINE orxVECTOR * orxVector_Normalize(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
546 {
547  register orxFLOAT fOp;
548 
549  /* Checks */
550  orxASSERT(_pvRes != orxNULL);
551  orxASSERT(_pvOp != orxNULL);
552 
553  /* Gets squared size */
554  fOp = (_pvOp->fX * _pvOp->fX) + (_pvOp->fY * _pvOp->fY) + (_pvOp->fZ * _pvOp->fZ);
555 
556  /* Gets reciprocal size */
558 
559  /* Updates result */
560  _pvRes->fX = fOp * _pvOp->fX;
561  _pvRes->fY = fOp * _pvOp->fY;
562  _pvRes->fZ = fOp * _pvOp->fZ;
563 
564  /* Done! */
565  return _pvRes;
566 }
567 
574 static orxINLINE orxVECTOR * orxVector_2DRotate(orxVECTOR *_pvRes, const orxVECTOR *_pvOp, orxFLOAT _fAngle)
575 {
576  /* Checks */
577  orxASSERT(_pvRes != orxNULL);
578  orxASSERT(_pvOp != orxNULL);
579 
580  /* PI/2? */
581  if(_fAngle == orxMATH_KF_PI_BY_2)
582  {
583  /* Updates result */
584  orxVector_Set(_pvRes, -_pvOp->fY, _pvOp->fX, _pvOp->fZ);
585  }
586  /* -PI/2? */
587  else if(_fAngle == -orxMATH_KF_PI_BY_2)
588  {
589  /* Updates result */
590  orxVector_Set(_pvRes, _pvOp->fY, -_pvOp->fX, _pvOp->fZ);
591  }
592  /* Any other angle */
593  else
594  {
595  register orxFLOAT fSin, fCos;
596 
597  /* Gets cos & sin of angle */
598  fCos = orxMath_Cos(_fAngle);
599  fSin = orxMath_Sin(_fAngle);
600 
601  /* Updates result */
602  orxVector_Set(_pvRes, (fCos * _pvOp->fX) - (fSin * _pvOp->fY), (fSin * _pvOp->fX) + (fCos * _pvOp->fY), _pvOp->fZ);
603  }
604 
605  /* Done! */
606  return _pvRes;
607 }
608 
613 static orxINLINE orxBOOL orxVector_IsNull(const orxVECTOR *_pvOp)
614 {
615  orxBOOL bResult;
616 
617  /* Checks */
618  orxASSERT(_pvOp != orxNULL);
619 
620  /* Updates result */
621  bResult = ((_pvOp->fX == orxFLOAT_0) && (_pvOp->fY == orxFLOAT_0) && (_pvOp->fZ == orxFLOAT_0)) ? orxTRUE : orxFALSE;
622 
623  /* Done! */
624  return bResult;
625 }
626 
632 static orxINLINE orxBOOL orxVector_AreEqual(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
633 {
634  orxBOOL bResult;
635 
636  /* Checks */
637  orxASSERT(_pvOp1 != orxNULL);
638  orxASSERT(_pvOp2 != orxNULL);
639 
640  /* Updates result */
641  bResult = ((_pvOp1->fX == _pvOp2->fX) && (_pvOp1->fY == _pvOp2->fY) && (_pvOp1->fZ == _pvOp2->fZ)) ? orxTRUE : orxFALSE;
642 
643  /* Done! */
644  return bResult;
645 }
646 
652 static orxINLINE orxVECTOR * orxVector_FromCartesianToSpherical(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
653 {
654  /* Checks */
655  orxASSERT(_pvRes != orxNULL);
656  orxASSERT(_pvOp != orxNULL);
657 
658  /* Is operand vector null? */
659  if((_pvOp->fX == orxFLOAT_0)
660  && (_pvOp->fY == orxFLOAT_0)
661  && (_pvOp->fZ == orxFLOAT_0))
662  {
663  /* Updates result vector */
664  _pvRes->fRho = _pvRes->fTheta = _pvRes->fPhi = orxFLOAT_0;
665  }
666  else
667  {
668  orxFLOAT fRho, fTheta, fPhi;
669 
670  /* Z = 0? */
671  if(_pvOp->fZ == orxFLOAT_0)
672  {
673  /* X = 0? */
674  if(_pvOp->fX == orxFLOAT_0)
675  {
676  /* Gets absolute value */
677  fRho = orxMath_Abs(_pvOp->fY);
678  }
679  /* X != 0 and Y = 0? */
680  else if(_pvOp->fY == orxFLOAT_0)
681  {
682  /* Gets absolute value */
683  fRho = orxMath_Abs(_pvOp->fX);
684  }
685  /* X != 0 and Y != 0 */
686  else
687  {
688  /* Computes rho */
689  fRho = orxMath_Sqrt((_pvOp->fX * _pvOp->fX) + (_pvOp->fY * _pvOp->fY));
690  }
691 
692  /* Sets phi */
693  fPhi = orxMATH_KF_PI_BY_2;
694  }
695  else
696  {
697  /* X = 0 and Y = 0? */
698  if((_pvOp->fX == orxFLOAT_0) && (_pvOp->fY == orxFLOAT_0))
699  {
700  /* Z < 0? */
701  if(_pvOp->fZ < orxFLOAT_0)
702  {
703  /* Gets absolute value */
704  fRho = orxMath_Abs(_pvOp->fZ);
705 
706  /* Sets phi */
707  fPhi = orxMATH_KF_PI;
708  }
709  else
710  {
711  /* Sets rho */
712  fRho = _pvOp->fZ;
713 
714  /* Sets phi */
715  fPhi = orxFLOAT_0;
716  }
717  }
718  else
719  {
720  /* Computes rho */
721  fRho = orxMath_Sqrt(orxVector_GetSquareSize(_pvOp));
722 
723  /* Computes phi */
724  fPhi = orxMath_ACos(_pvOp->fZ / fRho);
725  }
726  }
727 
728  /* Computes theta */
729  fTheta = orxMath_ATan(_pvOp->fY, _pvOp->fX);
730 
731  /* Updates result */
732  _pvRes->fRho = fRho;
733  _pvRes->fTheta = fTheta;
734  _pvRes->fPhi = fPhi;
735  }
736 
737  /* Done! */
738  return _pvRes;
739 }
740 
746 static orxINLINE orxVECTOR * orxVector_FromSphericalToCartesian(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
747 {
748  orxFLOAT fSinPhi, fCosPhi, fSinTheta, fCosTheta, fRho;
749 
750  /* Checks */
751  orxASSERT(_pvRes != orxNULL);
752  orxASSERT(_pvOp != orxNULL);
753 
754  /* Stores rho */
755  fRho = _pvOp->fRho;
756 
757  /* Gets sine & cosine */
758  fSinTheta = orxMath_Sin(_pvOp->fTheta);
759  fCosTheta = orxMath_Cos(_pvOp->fTheta);
760  fSinPhi = orxMath_Sin(_pvOp->fPhi);
761  fCosPhi = orxMath_Cos(_pvOp->fPhi);
762  if(orxMath_Abs(fSinTheta) < orxMATH_KF_EPSILON)
763  {
764  fSinTheta = orxFLOAT_0;
765  }
766  if(orxMath_Abs(fCosTheta) < orxMATH_KF_EPSILON)
767  {
768  fCosTheta = orxFLOAT_0;
769  }
770  if(orxMath_Abs(fSinPhi) < orxMATH_KF_EPSILON)
771  {
772  fSinPhi = orxFLOAT_0;
773  }
774  if(orxMath_Abs(fCosPhi) < orxMATH_KF_EPSILON)
775  {
776  fCosPhi = orxFLOAT_0;
777  }
778 
779  /* Updates result */
780  _pvRes->fX = fRho * fCosTheta * fSinPhi;
781  _pvRes->fY = fRho * fSinTheta * fSinPhi;
782  _pvRes->fZ = fRho * fCosPhi;
783 
784  /* Done! */
785  return _pvRes;
786 }
787 
793 static orxINLINE orxFLOAT orxVector_Dot(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
794 {
795  orxFLOAT fResult;
796 
797  /* Checks */
798  orxASSERT(_pvOp1 != orxNULL);
799  orxASSERT(_pvOp2 != orxNULL);
800 
801  /* Updates result */
802  fResult = (_pvOp1->fX * _pvOp2->fX) + (_pvOp1->fY * _pvOp2->fY) + (_pvOp1->fZ * _pvOp2->fZ);
803 
804  /* Done! */
805  return fResult;
806 }
807 
813 static orxINLINE orxFLOAT orxVector_2DDot(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
814 {
815  orxFLOAT fResult;
816 
817  /* Checks */
818  orxASSERT(_pvOp1 != orxNULL);
819  orxASSERT(_pvOp2 != orxNULL);
820 
821  /* Updates result */
822  fResult = (_pvOp1->fX * _pvOp2->fX) + (_pvOp1->fY * _pvOp2->fY);
823 
824  /* Done! */
825  return fResult;
826 }
827 
834 static orxINLINE orxVECTOR * orxVector_Cross(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
835 {
836  orxFLOAT fTemp1, fTemp2;
837 
838  /* Checks */
839  orxASSERT(_pvRes != orxNULL);
840  orxASSERT(_pvOp1 != orxNULL);
841  orxASSERT(_pvOp2 != orxNULL);
842 
843  /* Computes cross product */
844  fTemp1 = (_pvOp1->fY * _pvOp2->fZ) - (_pvOp1->fZ * _pvOp2->fY);
845  fTemp2 = (_pvOp1->fZ * _pvOp2->fX) - (_pvOp1->fX * _pvOp2->fZ);
846  _pvRes->fZ = (_pvOp1->fX * _pvOp2->fY) - (_pvOp1->fY * _pvOp2->fX);
847  _pvRes->fY = fTemp2;
848  _pvRes->fX = fTemp1;
849 
850  /* Done! */
851  return _pvRes;
852 }
853 
854 
855 /* *** Vector functions *** */
856 
866 extern orxDLLAPI orxVECTOR *orxFASTCALL orxVector_Bezier(orxVECTOR *_pvRes, const orxVECTOR *_pvPoint1, const orxVECTOR *_pvPoint2, const orxVECTOR *_pvPoint3, const orxVECTOR *_pvPoint4, orxFLOAT _fT);
867 
877 extern orxDLLAPI orxVECTOR *orxFASTCALL orxVector_CatmullRom(orxVECTOR *_pvRes, const orxVECTOR *_pvPoint1, const orxVECTOR *_pvPoint2, const orxVECTOR *_pvPoint3, const orxVECTOR *_pvPoint4, orxFLOAT _fT);
878 
879 
880 /* *** Vector constants *** */
881 
882 extern orxDLLAPI const orxVECTOR orxVECTOR_X;
883 extern orxDLLAPI const orxVECTOR orxVECTOR_Y;
884 extern orxDLLAPI const orxVECTOR orxVECTOR_Z;
886 extern orxDLLAPI const orxVECTOR orxVECTOR_0;
887 extern orxDLLAPI const orxVECTOR orxVECTOR_1;
889 extern orxDLLAPI const orxVECTOR orxVECTOR_RED;
890 extern orxDLLAPI const orxVECTOR orxVECTOR_GREEN;
891 extern orxDLLAPI const orxVECTOR orxVECTOR_BLUE;
892 extern orxDLLAPI const orxVECTOR orxVECTOR_YELLOW;
893 extern orxDLLAPI const orxVECTOR orxVECTOR_CYAN;
895 extern orxDLLAPI const orxVECTOR orxVECTOR_BLACK;
896 extern orxDLLAPI const orxVECTOR orxVECTOR_WHITE;
898 #ifdef __orxGCC__
899 
900  #pragma GCC diagnostic pop
901 
902 #endif /* __orxGCC__ */
903 
904 #endif /* _orxVECTOR_H_ */
905 
#define orxLERP(A, B, T)
Definition: orxMath.h:81
static orxINLINE orxFLOAT orxVector_GetSize(const orxVECTOR *_pvOp)
Definition: orxVector.h:478
static orxINLINE orxVECTOR * orxVector_Div(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:268
orxFLOAT fTheta
Definition: orxVector.h:78
orxDLLAPI const orxVECTOR orxVECTOR_CYAN
orxFLOAT fB
Definition: orxVector.h:87
static orxINLINE orxVECTOR * orxVector_Mulf(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, orxFLOAT _fOp2)
Definition: orxVector.h:198
orxDLLAPI const orxVECTOR orxVECTOR_YELLOW
static orxINLINE orxFLOAT orxMath_Round(orxFLOAT _fOp)
Definition: orxMath.h:519
static orxINLINE orxBOOL orxVector_AreEqual(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:632
static orxINLINE orxFLOAT orxVector_GetSquareDistance(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:497
static orxINLINE orxVECTOR * orxVector_Floor(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:421
orxDLLAPI const orxVECTOR orxVECTOR_BLACK
static orxINLINE orxFLOAT orxVector_Dot(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:793
static orxINLINE orxVECTOR * orxVector_Divf(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, orxFLOAT _fOp2)
Definition: orxVector.h:241
#define orxTRUE
Definition: orxType.h:186
static const orxFLOAT orxFLOAT_1
Definition: orxType.h:191
static orxINLINE orxVECTOR * orxVector_2DRotate(orxVECTOR *_pvRes, const orxVECTOR *_pvOp, orxFLOAT _fAngle)
Definition: orxVector.h:574
static orxINLINE orxVECTOR * orxVector_FromSphericalToCartesian(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:746
#define orxMIN(A, B)
Definition: orxMath.h:89
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:104
static orxINLINE orxFLOAT orxMath_Sqrt(orxFLOAT _fOp)
Definition: orxMath.h:474
orxDLLAPI const orxVECTOR orxVECTOR_Y
orxDLLAPI const orxVECTOR orxVECTOR_RED
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:185
static orxINLINE orxBOOL orxVector_IsNull(const orxVECTOR *_pvOp)
Definition: orxVector.h:613
static orxINLINE orxFLOAT orxMath_Sin(orxFLOAT _fOp)
Definition: orxMath.h:380
orxFLOAT fPhi
Definition: orxVector.h:86
static orxINLINE orxVECTOR * orxVector_Min(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:314
static orxINLINE orxVECTOR * orxVector_Neg(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:381
orxFLOAT fX
Definition: orxVector.h:69
orxFLOAT fS
Definition: orxVector.h:80
static orxINLINE orxFLOAT orxMath_Floor(orxFLOAT _fOp)
Definition: orxMath.h:489
static orxINLINE orxFLOAT orxVector_GetSquareSize(const orxVECTOR *_pvOp)
Definition: orxVector.h:460
static orxINLINE orxFLOAT orxMath_Abs(orxFLOAT _fOp)
Definition: orxMath.h:575
static orxINLINE orxFLOAT orxVector_2DDot(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:813
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
orxDLLAPI const orxVECTOR orxVECTOR_MAGENTA
orxFLOAT fG
Definition: orxVector.h:79
#define orxMAX(A, B)
Definition: orxMath.h:96
static orxINLINE orxVECTOR * orxVector_Clamp(orxVECTOR *_pvRes, const orxVECTOR *_pvOp, const orxVECTOR *_pvMin, const orxVECTOR *_pvMax)
Definition: orxVector.h:359
static orxINLINE orxFLOAT orxMath_ACos(orxFLOAT _fOp)
Definition: orxMath.h:425
#define orxMATH_KF_PI
Definition: orxMath.h:367
static orxINLINE orxFLOAT orxMath_Cos(orxFLOAT _fOp)
Definition: orxMath.h:395
static orxINLINE orxVECTOR * orxVector_Normalize(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:545
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:364
orxFLOAT fZ
Definition: orxVector.h:85
orxDLLAPI const orxVECTOR orxVECTOR_GREEN
orxDLLAPI const orxVECTOR orxVECTOR_BLUE
#define orxDLLAPI
Definition: orxDecl.h:394
static orxINLINE orxVECTOR * orxVector_FromCartesianToSpherical(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:652
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:441
orxDLLAPI const orxVECTOR orxVECTOR_WHITE
static orxINLINE orxVECTOR * orxVector_Cross(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:834
static const orxFLOAT orxFLOAT_0
Definition: orxType.h:190
#define orxMATH_KF_TINY_EPSILON
Definition: orxMath.h:365
orxDLLAPI const orxVECTOR orxVECTOR_0
static orxINLINE orxFLOAT orxMath_ATan(orxFLOAT _fOp1, orxFLOAT _fOp2)
Definition: orxMath.h:456
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:336
static orxINLINE void * orxMemory_Copy(void *_pDest, const void *_pSrc, orxU32 _u32Size)
Definition: orxMemory.h:159
orxFLOAT fL
Definition: orxVector.h:88
#define orxMATH_KF_PI_BY_2
Definition: orxMath.h:368
#define orxASSERT(TEST,...)
Definition: orxDebug.h:298
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:521
orxFLOAT fH
Definition: orxVector.h:72
static orxINLINE orxVECTOR * orxVector_Rec(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:401
orxDLLAPI const orxVECTOR orxVECTOR_Z
orxFLOAT fRho
Definition: orxVector.h:70

Generated for orx by doxygen 1.8.11