orx  stable
Portable Game Engine
orxVector.h
Go to the documentation of this file.
1 /* Orx - Portable Game Engine
2  *
3  * Copyright (c) 2008-2017 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 
55 typedef struct __orxVECTOR_t
56 {
58  union
59  {
60  orxFLOAT fX;
61  orxFLOAT fRho;
62  orxFLOAT fR;
63  orxFLOAT fH;
64  };
65 
66  union
67  {
68  orxFLOAT fY;
69  orxFLOAT fTheta;
70  orxFLOAT fG;
71  orxFLOAT fS;
72  };
73 
74  union
75  {
76  orxFLOAT fZ;
77  orxFLOAT fPhi;
78  orxFLOAT fB;
79  orxFLOAT fL;
80  orxFLOAT fV;
81  };
82 
83 } orxVECTOR;
84 
85 
86 /* *** Vector inlined functions *** */
87 
88 
96 static orxINLINE orxVECTOR * orxVector_Set(orxVECTOR *_pvVec, orxFLOAT _fX, orxFLOAT _fY, orxFLOAT _fZ)
97 {
98  /* Checks */
99  orxASSERT(_pvVec != orxNULL);
100 
101  /* Stores values */
102  _pvVec->fX = _fX;
103  _pvVec->fY = _fY;
104  _pvVec->fZ = _fZ;
105 
106  /* Done ! */
107  return _pvVec;
108 }
109 
115 static orxINLINE orxVECTOR * orxVector_SetAll(orxVECTOR *_pvVec, orxFLOAT _fValue)
116 {
117  /* Done ! */
118  return(orxVector_Set(_pvVec, _fValue, _fValue, _fValue));
119 }
120 
126 static orxINLINE orxVECTOR * orxVector_Copy(orxVECTOR *_pvDst, const orxVECTOR *_pvSrc)
127 {
128  /* Checks */
129  orxASSERT(_pvDst != orxNULL);
130  orxASSERT(_pvSrc != orxNULL);
131 
132  /* Copies it */
133  orxMemory_Copy(_pvDst, _pvSrc, sizeof(orxVECTOR));
134 
135  /* Done! */
136  return _pvDst;
137 }
138 
145 static orxINLINE orxVECTOR * orxVector_Add(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
146 {
147  /* Checks */
148  orxASSERT(_pvRes != orxNULL);
149  orxASSERT(_pvOp1 != orxNULL);
150  orxASSERT(_pvOp2 != orxNULL);
151 
152  /* Adds all */
153  _pvRes->fX = _pvOp1->fX + _pvOp2->fX;
154  _pvRes->fY = _pvOp1->fY + _pvOp2->fY;
155  _pvRes->fZ = _pvOp1->fZ + _pvOp2->fZ;
156 
157  /* Done! */
158  return _pvRes;
159 }
160 
167 static orxINLINE orxVECTOR * orxVector_Sub(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
168 {
169  /* Checks */
170  orxASSERT(_pvRes != orxNULL);
171  orxASSERT(_pvOp1 != orxNULL);
172  orxASSERT(_pvOp2 != orxNULL);
173 
174  /* Adds all */
175  _pvRes->fX = _pvOp1->fX - _pvOp2->fX;
176  _pvRes->fY = _pvOp1->fY - _pvOp2->fY;
177  _pvRes->fZ = _pvOp1->fZ - _pvOp2->fZ;
178 
179  /* Done! */
180  return _pvRes;
181 }
182 
189 static orxINLINE orxVECTOR * orxVector_Mulf(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, orxFLOAT _fOp2)
190 {
191  /* Checks */
192  orxASSERT(_pvRes != orxNULL);
193  orxASSERT(_pvOp1 != orxNULL);
194 
195  /* Muls all */
196  _pvRes->fX = _pvOp1->fX * _fOp2;
197  _pvRes->fY = _pvOp1->fY * _fOp2;
198  _pvRes->fZ = _pvOp1->fZ * _fOp2;
199 
200  /* Done! */
201  return _pvRes;
202 }
203 
210 static orxINLINE orxVECTOR * orxVector_Mul(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
211 {
212  /* Checks */
213  orxASSERT(_pvRes != orxNULL);
214  orxASSERT(_pvOp1 != orxNULL);
215  orxASSERT(_pvOp2 != orxNULL);
216 
217  /* Muls all */
218  _pvRes->fX = _pvOp1->fX * _pvOp2->fX;
219  _pvRes->fY = _pvOp1->fY * _pvOp2->fY;
220  _pvRes->fZ = _pvOp1->fZ * _pvOp2->fZ;
221 
222  /* Done! */
223  return _pvRes;
224 }
225 
232 static orxINLINE orxVECTOR * orxVector_Divf(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, orxFLOAT _fOp2)
233 {
234  register orxFLOAT fRecCoef;
235 
236  /* Checks */
237  orxASSERT(_pvRes != orxNULL);
238  orxASSERT(_pvOp1 != orxNULL);
239  orxASSERT(_fOp2 != orxFLOAT_0);
240 
241  /* Gets reciprocal coef */
242  fRecCoef = orxFLOAT_1 / _fOp2;
243 
244  /* Muls all */
245  _pvRes->fX = _pvOp1->fX * fRecCoef;
246  _pvRes->fY = _pvOp1->fY * fRecCoef;
247  _pvRes->fZ = _pvOp1->fZ * fRecCoef;
248 
249  /* Done! */
250  return _pvRes;
251 }
252 
259 static orxINLINE orxVECTOR * orxVector_Div(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
260 {
261  /* Checks */
262  orxASSERT(_pvRes != orxNULL);
263  orxASSERT(_pvOp1 != orxNULL);
264  orxASSERT(_pvOp2 != orxNULL);
265 
266  /* Divs all */
267  _pvRes->fX = _pvOp1->fX / _pvOp2->fX;
268  _pvRes->fY = _pvOp1->fY / _pvOp2->fY;
269  _pvRes->fZ = _pvOp1->fZ / _pvOp2->fZ;
270 
271  /* Done! */
272  return _pvRes;
273 }
274 
282 static orxINLINE orxVECTOR * orxVector_Lerp(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2, orxFLOAT _fOp)
283 {
284  /* Checks */
285  orxASSERT(_pvRes != orxNULL);
286  orxASSERT(_pvOp1 != orxNULL);
287  orxASSERT(_pvOp2 != orxNULL);
288  orxASSERT(_fOp >= orxFLOAT_0);
289 
290  /* Lerps all*/
291  _pvRes->fX = orxLERP(_pvOp1->fX, _pvOp2->fX, _fOp);
292  _pvRes->fY = orxLERP(_pvOp1->fY, _pvOp2->fY, _fOp);
293  _pvRes->fZ = orxLERP(_pvOp1->fZ, _pvOp2->fZ, _fOp);
294 
295  /* Done! */
296  return _pvRes;
297 }
298 
305 static orxINLINE orxVECTOR * orxVector_Min(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
306 {
307  /* Checks */
308  orxASSERT(_pvRes != orxNULL);
309  orxASSERT(_pvOp1 != orxNULL);
310  orxASSERT(_pvOp2 != orxNULL);
311 
312  /* Gets all mins */
313  _pvRes->fX = orxMIN(_pvOp1->fX, _pvOp2->fX);
314  _pvRes->fY = orxMIN(_pvOp1->fY, _pvOp2->fY);
315  _pvRes->fZ = orxMIN(_pvOp1->fZ, _pvOp2->fZ);
316 
317  /* Done! */
318  return _pvRes;
319 }
320 
327 static orxINLINE orxVECTOR * orxVector_Max(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
328 {
329  /* Checks */
330  orxASSERT(_pvRes != orxNULL);
331  orxASSERT(_pvOp1 != orxNULL);
332  orxASSERT(_pvOp2 != orxNULL);
333 
334  /* Gets all maxs */
335  _pvRes->fX = orxMAX(_pvOp1->fX, _pvOp2->fX);
336  _pvRes->fY = orxMAX(_pvOp1->fY, _pvOp2->fY);
337  _pvRes->fZ = orxMAX(_pvOp1->fZ, _pvOp2->fZ);
338 
339  /* Done! */
340  return _pvRes;
341 }
342 
350 static orxINLINE orxVECTOR * orxVector_Clamp(orxVECTOR *_pvRes, const orxVECTOR *_pvOp, const orxVECTOR *_pvMin, const orxVECTOR *_pvMax)
351 {
352  /* Checks */
353  orxASSERT(_pvRes != orxNULL);
354  orxASSERT(_pvOp != orxNULL);
355  orxASSERT(_pvMin != orxNULL);
356  orxASSERT(_pvMax != orxNULL);
357 
358  /* Gets all clamped values */
359  _pvRes->fX = orxCLAMP(_pvOp->fX, _pvMin->fX, _pvMax->fX);
360  _pvRes->fY = orxCLAMP(_pvOp->fY, _pvMin->fY, _pvMax->fY);
361  _pvRes->fZ = orxCLAMP(_pvOp->fZ, _pvMin->fZ, _pvMax->fZ);
362 
363  /* Done! */
364  return _pvRes;
365 }
366 
372 static orxINLINE orxVECTOR * orxVector_Neg(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
373 {
374  /* Checks */
375  orxASSERT(_pvRes != orxNULL);
376  orxASSERT(_pvOp != orxNULL);
377 
378  /* Negates all */
379  _pvRes->fX = -(_pvOp->fX);
380  _pvRes->fY = -(_pvOp->fY);
381  _pvRes->fZ = -(_pvOp->fZ);
382 
383  /* Done! */
384  return _pvRes;
385 }
386 
392 static orxINLINE orxVECTOR * orxVector_Rec(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
393 {
394  /* Checks */
395  orxASSERT(_pvRes != orxNULL);
396  orxASSERT(_pvOp != orxNULL);
397 
398  /* Reverts all */
399  _pvRes->fX = orxFLOAT_1 / _pvOp->fX;
400  _pvRes->fY = orxFLOAT_1 / _pvOp->fY;
401  _pvRes->fZ = orxFLOAT_1 / _pvOp->fZ;
402 
403  /* Done! */
404  return _pvRes;
405 }
406 
412 static orxINLINE orxVECTOR * orxVector_Floor(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
413 {
414  /* Checks */
415  orxASSERT(_pvRes != orxNULL);
416  orxASSERT(_pvOp != orxNULL);
417 
418  /* Reverts all */
419  _pvRes->fX = orxMath_Floor(_pvOp->fX);
420  _pvRes->fY = orxMath_Floor(_pvOp->fY);
421  _pvRes->fZ = orxMath_Floor(_pvOp->fZ);
422 
423  /* Done! */
424  return _pvRes;
425 }
426 
432 static orxINLINE orxVECTOR * orxVector_Round(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
433 {
434  /* Checks */
435  orxASSERT(_pvRes != orxNULL);
436  orxASSERT(_pvOp != orxNULL);
437 
438  /* Reverts all */
439  _pvRes->fX = orxMath_Round(_pvOp->fX);
440  _pvRes->fY = orxMath_Round(_pvOp->fY);
441  _pvRes->fZ = orxMath_Round(_pvOp->fZ);
442 
443  /* Done! */
444  return _pvRes;
445 }
446 
451 static orxINLINE orxFLOAT orxVector_GetSquareSize(const orxVECTOR *_pvOp)
452 {
453  register orxFLOAT fResult;
454 
455  /* Checks */
456  orxASSERT(_pvOp != orxNULL);
457 
458  /* Updates result */
459  fResult = (_pvOp->fX * _pvOp->fX) + (_pvOp->fY * _pvOp->fY) + (_pvOp->fZ * _pvOp->fZ);
460 
461  /* Done! */
462  return fResult;
463 }
464 
469 static orxINLINE orxFLOAT orxVector_GetSize(const orxVECTOR *_pvOp)
470 {
471  register orxFLOAT fResult;
472 
473  /* Checks */
474  orxASSERT(_pvOp != orxNULL);
475 
476  /* Updates result */
477  fResult = orxMath_Sqrt((_pvOp->fX * _pvOp->fX) + (_pvOp->fY * _pvOp->fY) + (_pvOp->fZ * _pvOp->fZ));
478 
479  /* Done! */
480  return fResult;
481 }
482 
488 static orxINLINE orxFLOAT orxVector_GetSquareDistance(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
489 {
490  orxVECTOR vTemp;
491  register orxFLOAT fResult;
492 
493  /* Checks */
494  orxASSERT(_pvOp1 != orxNULL);
495  orxASSERT(_pvOp2 != orxNULL);
496 
497  /* Gets distance vector */
498  orxVector_Sub(&vTemp, _pvOp2, _pvOp1);
499 
500  /* Updates result */
501  fResult = orxVector_GetSquareSize(&vTemp);
502 
503  /* Done! */
504  return fResult;
505 }
506 
512 static orxINLINE orxFLOAT orxVector_GetDistance(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
513 {
514  orxVECTOR vTemp;
515  register orxFLOAT fResult;
516 
517  /* Checks */
518  orxASSERT(_pvOp1 != orxNULL);
519  orxASSERT(_pvOp2 != orxNULL);
520 
521  /* Gets distance vector */
522  orxVector_Sub(&vTemp, _pvOp2, _pvOp1);
523 
524  /* Updates result */
525  fResult = orxVector_GetSize(&vTemp);
526 
527  /* Done! */
528  return fResult;
529 }
530 
536 static orxINLINE orxVECTOR * orxVector_Normalize(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
537 {
538  register orxFLOAT fOp;
539 
540  /* Checks */
541  orxASSERT(_pvRes != orxNULL);
542  orxASSERT(_pvOp != orxNULL);
543 
544  /* Gets squared size */
545  fOp = (_pvOp->fX * _pvOp->fX) + (_pvOp->fY * _pvOp->fY) + (_pvOp->fZ * _pvOp->fZ);
546 
547  /* Gets reciprocal size */
549 
550  /* Updates result */
551  _pvRes->fX = fOp * _pvOp->fX;
552  _pvRes->fY = fOp * _pvOp->fY;
553  _pvRes->fZ = fOp * _pvOp->fZ;
554 
555  /* Done! */
556  return _pvRes;
557 }
558 
565 static orxINLINE orxVECTOR * orxVector_2DRotate(orxVECTOR *_pvRes, const orxVECTOR *_pvOp, orxFLOAT _fAngle)
566 {
567  /* Checks */
568  orxASSERT(_pvRes != orxNULL);
569  orxASSERT(_pvOp != orxNULL);
570 
571  /* PI/2? */
572  if(_fAngle == orxMATH_KF_PI_BY_2)
573  {
574  /* Updates result */
575  orxVector_Set(_pvRes, -_pvOp->fY, _pvOp->fX, _pvOp->fZ);
576  }
577  /* -PI/2? */
578  else if(_fAngle == -orxMATH_KF_PI_BY_2)
579  {
580  /* Updates result */
581  orxVector_Set(_pvRes, _pvOp->fY, -_pvOp->fX, _pvOp->fZ);
582  }
583  /* Any other angle */
584  else
585  {
586  register orxFLOAT fSin, fCos;
587 
588  /* Gets cos & sin of angle */
589  fCos = orxMath_Cos(_fAngle);
590  fSin = orxMath_Sin(_fAngle);
591 
592  /* Updates result */
593  orxVector_Set(_pvRes, (fCos * _pvOp->fX) - (fSin * _pvOp->fY), (fSin * _pvOp->fX) + (fCos * _pvOp->fY), _pvOp->fZ);
594  }
595 
596  /* Done! */
597  return _pvRes;
598 }
599 
604 static orxINLINE orxBOOL orxVector_IsNull(const orxVECTOR *_pvOp)
605 {
606  orxBOOL bResult;
607 
608  /* Checks */
609  orxASSERT(_pvOp != orxNULL);
610 
611  /* Updates result */
612  bResult = ((_pvOp->fX == orxFLOAT_0) && (_pvOp->fY == orxFLOAT_0) && (_pvOp->fZ == orxFLOAT_0)) ? orxTRUE : orxFALSE;
613 
614  /* Done! */
615  return bResult;
616 }
617 
623 static orxINLINE orxBOOL orxVector_AreEqual(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
624 {
625  orxBOOL bResult;
626 
627  /* Checks */
628  orxASSERT(_pvOp1 != orxNULL);
629  orxASSERT(_pvOp2 != orxNULL);
630 
631  /* Updates result */
632  bResult = ((_pvOp1->fX == _pvOp2->fX) && (_pvOp1->fY == _pvOp2->fY) && (_pvOp1->fZ == _pvOp2->fZ)) ? orxTRUE : orxFALSE;
633 
634  /* Done! */
635  return bResult;
636 }
637 
643 static orxINLINE orxVECTOR * orxVector_FromCartesianToSpherical(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
644 {
645  /* Checks */
646  orxASSERT(_pvRes != orxNULL);
647  orxASSERT(_pvOp != orxNULL);
648 
649  /* Is operand vector null? */
650  if((_pvOp->fX == orxFLOAT_0)
651  && (_pvOp->fY == orxFLOAT_0)
652  && (_pvOp->fZ == orxFLOAT_0))
653  {
654  /* Updates result vector */
655  _pvRes->fRho = _pvRes->fTheta = _pvRes->fPhi = orxFLOAT_0;
656  }
657  else
658  {
659  orxFLOAT fRho, fTheta, fPhi;
660 
661  /* Z = 0? */
662  if(_pvOp->fZ == orxFLOAT_0)
663  {
664  /* X = 0? */
665  if(_pvOp->fX == orxFLOAT_0)
666  {
667  /* Gets absolute value */
668  fRho = orxMath_Abs(_pvOp->fY);
669  }
670  /* X != 0 and Y = 0? */
671  else if(_pvOp->fY == orxFLOAT_0)
672  {
673  /* Gets absolute value */
674  fRho = orxMath_Abs(_pvOp->fX);
675  }
676  /* X != 0 and Y != 0 */
677  else
678  {
679  /* Computes rho */
680  fRho = orxMath_Sqrt((_pvOp->fX * _pvOp->fX) + (_pvOp->fY * _pvOp->fY));
681  }
682 
683  /* Sets phi */
684  fPhi = orxMATH_KF_PI_BY_2;
685  }
686  else
687  {
688  /* X = 0 and Y = 0? */
689  if((_pvOp->fX == orxFLOAT_0) && (_pvOp->fY == orxFLOAT_0))
690  {
691  /* Z < 0? */
692  if(_pvOp->fZ < orxFLOAT_0)
693  {
694  /* Gets absolute value */
695  fRho = orxMath_Abs(_pvOp->fZ);
696 
697  /* Sets phi */
698  fPhi = orxMATH_KF_PI;
699  }
700  else
701  {
702  /* Sets rho */
703  fRho = _pvOp->fZ;
704 
705  /* Sets phi */
706  fPhi = orxFLOAT_0;
707  }
708  }
709  else
710  {
711  /* Computes rho */
712  fRho = orxMath_Sqrt(orxVector_GetSquareSize(_pvOp));
713 
714  /* Computes phi */
715  fPhi = orxMath_ACos(_pvOp->fZ / fRho);
716  }
717  }
718 
719  /* Computes theta */
720  fTheta = orxMath_ATan(_pvOp->fY, _pvOp->fX);
721 
722  /* Updates result */
723  _pvRes->fRho = fRho;
724  _pvRes->fTheta = fTheta;
725  _pvRes->fPhi = fPhi;
726  }
727 
728  /* Done! */
729  return _pvRes;
730 }
731 
737 static orxINLINE orxVECTOR * orxVector_FromSphericalToCartesian(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
738 {
739  orxFLOAT fSinPhi, fCosPhi, fSinTheta, fCosTheta, fRho;
740 
741  /* Checks */
742  orxASSERT(_pvRes != orxNULL);
743  orxASSERT(_pvOp != orxNULL);
744 
745  /* Stores rho */
746  fRho = _pvOp->fRho;
747 
748  /* Gets sine & cosine */
749  fSinTheta = orxMath_Sin(_pvOp->fTheta);
750  fCosTheta = orxMath_Cos(_pvOp->fTheta);
751  fSinPhi = orxMath_Sin(_pvOp->fPhi);
752  fCosPhi = orxMath_Cos(_pvOp->fPhi);
753  if(orxMath_Abs(fSinTheta) < orxMATH_KF_EPSILON)
754  {
755  fSinTheta = orxFLOAT_0;
756  }
757  if(orxMath_Abs(fCosTheta) < orxMATH_KF_EPSILON)
758  {
759  fCosTheta = orxFLOAT_0;
760  }
761  if(orxMath_Abs(fSinPhi) < orxMATH_KF_EPSILON)
762  {
763  fSinPhi = orxFLOAT_0;
764  }
765  if(orxMath_Abs(fCosPhi) < orxMATH_KF_EPSILON)
766  {
767  fCosPhi = orxFLOAT_0;
768  }
769 
770  /* Updates result */
771  _pvRes->fX = fRho * fCosTheta * fSinPhi;
772  _pvRes->fY = fRho * fSinTheta * fSinPhi;
773  _pvRes->fZ = fRho * fCosPhi;
774 
775  /* Done! */
776  return _pvRes;
777 }
778 
784 static orxINLINE orxFLOAT orxVector_Dot(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
785 {
786  orxFLOAT fResult;
787 
788  /* Checks */
789  orxASSERT(_pvOp1 != orxNULL);
790  orxASSERT(_pvOp2 != orxNULL);
791 
792  /* Updates result */
793  fResult = (_pvOp1->fX * _pvOp2->fX) + (_pvOp1->fY * _pvOp2->fY) + (_pvOp1->fZ * _pvOp2->fZ);
794 
795  /* Done! */
796  return fResult;
797 }
798 
804 static orxINLINE orxFLOAT orxVector_2DDot(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
805 {
806  orxFLOAT fResult;
807 
808  /* Checks */
809  orxASSERT(_pvOp1 != orxNULL);
810  orxASSERT(_pvOp2 != orxNULL);
811 
812  /* Updates result */
813  fResult = (_pvOp1->fX * _pvOp2->fX) + (_pvOp1->fY * _pvOp2->fY);
814 
815  /* Done! */
816  return fResult;
817 }
818 
825 static orxINLINE orxVECTOR * orxVector_Cross(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
826 {
827  orxFLOAT fTemp1, fTemp2;
828 
829  /* Checks */
830  orxASSERT(_pvRes != orxNULL);
831  orxASSERT(_pvOp1 != orxNULL);
832  orxASSERT(_pvOp2 != orxNULL);
833 
834  /* Computes cross product */
835  fTemp1 = (_pvOp1->fY * _pvOp2->fZ) - (_pvOp1->fZ * _pvOp2->fY);
836  fTemp2 = (_pvOp1->fZ * _pvOp2->fX) - (_pvOp1->fX * _pvOp2->fZ);
837  _pvRes->fZ = (_pvOp1->fX * _pvOp2->fY) - (_pvOp1->fY * _pvOp2->fX);
838  _pvRes->fY = fTemp2;
839  _pvRes->fX = fTemp1;
840 
841  /* Done! */
842  return _pvRes;
843 }
844 
845 
846 /* *** Vector functions *** */
847 
857 extern orxDLLAPI orxVECTOR *orxFASTCALL orxVector_Bezier(orxVECTOR *_pvRes, const orxVECTOR *_pvPoint1, const orxVECTOR *_pvPoint2, const orxVECTOR *_pvPoint3, const orxVECTOR *_pvPoint4, orxFLOAT _fT);
858 
868 extern orxDLLAPI orxVECTOR *orxFASTCALL orxVector_CatmullRom(orxVECTOR *_pvRes, const orxVECTOR *_pvPoint1, const orxVECTOR *_pvPoint2, const orxVECTOR *_pvPoint3, const orxVECTOR *_pvPoint4, orxFLOAT _fT);
869 
870 
871 /* *** Vector constants *** */
872 
873 extern orxDLLAPI const orxVECTOR orxVECTOR_X;
874 extern orxDLLAPI const orxVECTOR orxVECTOR_Y;
875 extern orxDLLAPI const orxVECTOR orxVECTOR_Z;
877 extern orxDLLAPI const orxVECTOR orxVECTOR_0;
878 extern orxDLLAPI const orxVECTOR orxVECTOR_1;
880 extern orxDLLAPI const orxVECTOR orxVECTOR_RED;
881 extern orxDLLAPI const orxVECTOR orxVECTOR_GREEN;
882 extern orxDLLAPI const orxVECTOR orxVECTOR_BLUE;
883 extern orxDLLAPI const orxVECTOR orxVECTOR_YELLOW;
884 extern orxDLLAPI const orxVECTOR orxVECTOR_CYAN;
886 extern orxDLLAPI const orxVECTOR orxVECTOR_BLACK;
887 extern orxDLLAPI const orxVECTOR orxVECTOR_WHITE;
889 #endif /* _orxVECTOR_H_ */
890 
#define orxLERP(A, B, T)
Definition: orxMath.h:63
static orxINLINE orxFLOAT orxVector_GetSize(const orxVECTOR *_pvOp)
Definition: orxVector.h:469
static orxINLINE orxVECTOR * orxVector_Div(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:259
orxFLOAT fTheta
Definition: orxVector.h:69
orxDLLAPI const orxVECTOR orxVECTOR_CYAN
orxFLOAT fB
Definition: orxVector.h:78
static orxINLINE orxVECTOR * orxVector_Mulf(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, orxFLOAT _fOp2)
Definition: orxVector.h:189
orxDLLAPI const orxVECTOR orxVECTOR_YELLOW
static orxINLINE orxFLOAT orxMath_Round(orxFLOAT _fOp)
Definition: orxMath.h:445
static orxINLINE orxBOOL orxVector_AreEqual(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:623
static orxINLINE orxFLOAT orxVector_GetSquareDistance(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:488
static orxINLINE orxVECTOR * orxVector_Floor(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:412
orxDLLAPI const orxVECTOR orxVECTOR_BLACK
static orxINLINE orxFLOAT orxVector_Dot(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:784
static orxINLINE orxVECTOR * orxVector_Divf(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, orxFLOAT _fOp2)
Definition: orxVector.h:232
#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:565
static orxINLINE orxVECTOR * orxVector_FromSphericalToCartesian(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:737
#define orxMIN(A, B)
Definition: orxMath.h:71
static orxINLINE orxVECTOR * orxVector_Mul(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:210
orxFLOAT fY
Definition: orxVector.h:68
orxDLLAPI const orxVECTOR orxVECTOR_1
#define orxCLAMP(V, MIN, MAX)
Definition: orxMath.h:86
static orxINLINE orxFLOAT orxMath_Sqrt(orxFLOAT _fOp)
Definition: orxMath.h:400
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:604
static orxINLINE orxFLOAT orxMath_Sin(orxFLOAT _fOp)
Definition: orxMath.h:306
orxFLOAT fPhi
Definition: orxVector.h:77
static orxINLINE orxVECTOR * orxVector_Min(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:305
static orxINLINE orxVECTOR * orxVector_Neg(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:372
orxFLOAT fX
Definition: orxVector.h:60
orxFLOAT fS
Definition: orxVector.h:71
static orxINLINE orxFLOAT orxMath_Floor(orxFLOAT _fOp)
Definition: orxMath.h:415
static orxINLINE orxFLOAT orxVector_GetSquareSize(const orxVECTOR *_pvOp)
Definition: orxVector.h:451
static orxINLINE orxFLOAT orxMath_Abs(orxFLOAT _fOp)
Definition: orxMath.h:501
static orxINLINE orxFLOAT orxVector_2DDot(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:804
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:96
static orxINLINE orxVECTOR * orxVector_Lerp(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2, orxFLOAT _fOp)
Definition: orxVector.h:282
orxDLLAPI const orxVECTOR orxVECTOR_MAGENTA
orxFLOAT fG
Definition: orxVector.h:70
#define orxMAX(A, B)
Definition: orxMath.h:78
static orxINLINE orxVECTOR * orxVector_Clamp(orxVECTOR *_pvRes, const orxVECTOR *_pvOp, const orxVECTOR *_pvMin, const orxVECTOR *_pvMax)
Definition: orxVector.h:350
static orxINLINE orxFLOAT orxMath_ACos(orxFLOAT _fOp)
Definition: orxMath.h:351
#define orxMATH_KF_PI
Definition: orxMath.h:293
static orxINLINE orxFLOAT orxMath_Cos(orxFLOAT _fOp)
Definition: orxMath.h:321
static orxINLINE orxVECTOR * orxVector_Normalize(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:536
orxFLOAT fR
Definition: orxVector.h:62
static orxINLINE orxVECTOR * orxVector_Add(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:145
#define orxMATH_KF_EPSILON
Definition: orxMath.h:290
orxFLOAT fZ
Definition: orxVector.h:76
orxDLLAPI const orxVECTOR orxVECTOR_GREEN
orxDLLAPI const orxVECTOR orxVECTOR_BLUE
#define orxDLLAPI
Definition: orxDecl.h:387
static orxINLINE orxVECTOR * orxVector_FromCartesianToSpherical(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:643
orxDLLAPI const orxVECTOR orxVECTOR_X
orxFLOAT fV
Definition: orxVector.h:80
static orxINLINE orxVECTOR * orxVector_SetAll(orxVECTOR *_pvVec, orxFLOAT _fValue)
Definition: orxVector.h:115
static orxINLINE orxVECTOR * orxVector_Round(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:432
orxDLLAPI const orxVECTOR orxVECTOR_WHITE
static orxINLINE orxVECTOR * orxVector_Cross(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:825
static const orxFLOAT orxFLOAT_0
Definition: orxType.h:190
#define orxMATH_KF_TINY_EPSILON
Definition: orxMath.h:291
orxDLLAPI const orxVECTOR orxVECTOR_0
static orxINLINE orxFLOAT orxMath_ATan(orxFLOAT _fOp1, orxFLOAT _fOp2)
Definition: orxMath.h:382
static orxINLINE orxVECTOR * orxVector_Sub(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:167
static orxINLINE orxVECTOR * orxVector_Max(orxVECTOR *_pvRes, const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:327
static orxINLINE void * orxMemory_Copy(void *_pDest, const void *_pSrc, orxU32 _u32Size)
Definition: orxMemory.h:159
orxFLOAT fL
Definition: orxVector.h:79
#define orxMATH_KF_PI_BY_2
Definition: orxMath.h:294
#define orxASSERT(TEST,...)
Definition: orxDebug.h:298
static orxINLINE orxVECTOR * orxVector_Copy(orxVECTOR *_pvDst, const orxVECTOR *_pvSrc)
Definition: orxVector.h:126
static orxINLINE orxFLOAT orxVector_GetDistance(const orxVECTOR *_pvOp1, const orxVECTOR *_pvOp2)
Definition: orxVector.h:512
orxFLOAT fH
Definition: orxVector.h:63
static orxINLINE orxVECTOR * orxVector_Rec(orxVECTOR *_pvRes, const orxVECTOR *_pvOp)
Definition: orxVector.h:392
orxDLLAPI const orxVECTOR orxVECTOR_Z
orxFLOAT fRho
Definition: orxVector.h:61

Generated for orx by doxygen 1.5.6