Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cVecT.h
Go to the documentation of this file.
1 //
6 
7 #ifndef _INC_cVecT_H
8 #define _INC_cVecT_H
9 #ifndef NO_PRAGMA_ONCE
10 #pragma once
11 #endif
12 
13 #include "Calc.h"
14 #include "GrayCore/include/cValT.h"
15 #include "GrayCore/include/cMem.h"
16 
17 namespace GrayLib
18 {
20  {
31  };
32 
34  typedef float DVALUEDEF_t;
35 
36  template<typename TYPE, int _IQTY, class _TYPE_C>
38  {
46  public:
47  static const int k_nDim = _IQTY;
48  typedef TYPE DVALUE_t;
50 
51  TYPE* get_T() noexcept
52  {
53  return (TYPE*)this;
54  }
55  const TYPE* get_CT() const noexcept
56  {
57  return (const TYPE*)this;
58  }
59  const _TYPE_C& get_CR() const noexcept
60  {
61  return *((_TYPE_C*)this);
62  }
63 
64  operator const TYPE*() const noexcept
65  {
68  return get_CT();
69  }
70  TYPE GetElem(int i) const noexcept
71  {
73  DEBUG_CHECK(IS_INDEX_GOOD(i, _IQTY));
74  return get_CT()[i];
75  }
76  inline TYPE operator[] (int i) const noexcept
77  {
78  // just so there is no confusion with auto generated TYPE* []
79  return GetElem(i);
80  }
81 
82  // const get operators.
83 
84  bool isZero() const noexcept
85  {
87  for (int i = 0; i < _IQTY; i++)
88  {
89  if (get_CT()[i] != (TYPE)0)
90  return false;
91  }
92  return true;
93  }
94 
95  COMPARE_t Compare(const THIS_t& v2) const noexcept
96  {
97  return ::memcmp(get_CT(), v2.get_CT(), sizeof(TYPE)*_IQTY);
98  }
99  bool operator == (const THIS_t& v2) const noexcept
100  {
101  return Compare(v2) == 0 ;
102  }
103  bool operator != (const THIS_t& v2) const noexcept
104  {
105  return Compare(v2) != 0 ;
106  }
107 
108  bool IsNear(const THIS_t& v2, TYPE fDist = (TYPE)k_FLT_MIN2) const
109  {
110  for (int i = 0; i < _IQTY; i++)
111  {
112  if (!Calc::IsNear(get_CT()[i], v2.get_CT()[i], fDist))
113  return false;
114  }
115  return true;
116  }
117 
118  inline TYPE get_MagnitudeSq() const noexcept
119  {
122  TYPE nMagnitude = 0;
123  for (int i = 0; i < _IQTY; i++)
124  {
125  nMagnitude += Calc::Sqr(GetElem(i));
126  }
127  return nMagnitude;
128  }
129  inline TYPE get_Magnitude() const noexcept
130  {
133  return Calc::Sqrt(get_MagnitudeSq()) ;
134  }
135 
136  _TYPE_C operator -() const
137  {
139  _TYPE_C vr;
140  for (int i = 0; i < _IQTY; i++)
141  {
142  vr.RefElem(i) = -GetElem(i);
143  }
144  return vr;
145  }
146  _TYPE_C get_Abs() const
147  {
148  _TYPE_C vr;
149  for (int i = 0; i < _IQTY; i++)
150  {
151  vr.RefElem(i) = Calc::Abs(GetElem(i));
152  }
153  return vr;
154  }
155  inline _TYPE_C GetSum(const THIS_t& v2) const
156  {
159  _TYPE_C vr;
160  for (int i = 0; i < _IQTY; i++)
161  {
162  vr.RefElem(i) = GetElem(i) + v2.GetElem(i);
163  }
164  return vr;
165  }
166  inline _TYPE_C operator + (const THIS_t& v2) const
167  {
168  return GetSum(v2);
169  }
170  inline _TYPE_C GetDiff(const THIS_t& v2) const
171  {
173  _TYPE_C vr;
174  for (int i = 0; i < _IQTY; i++)
175  {
176  vr.RefElem(i) = GetElem(i) - v2.GetElem(i);
177  }
178  return vr;
179  }
180  inline _TYPE_C operator - (const THIS_t& v2) const
181  {
182  return GetDiff(v2);
183  }
184  inline _TYPE_C GetScaled(TYPE nScale) const
185  {
187  _TYPE_C vr;
188  for (int i = 0; i < _IQTY; i++)
189  {
190  vr.RefElem(i) = GetElem(i) * nScale;
191  }
192  return vr;
193  }
194  inline _TYPE_C operator * (TYPE nScale) const
195  {
197  return GetScaled(nScale);
198  }
199  _TYPE_C operator / (TYPE nScale) const
200  {
201  ASSERT(nScale);
202  return GetScaled(((TYPE)1) / nScale);
203  }
204 
205  inline _TYPE_C GetMul(const THIS_t& v2) const
206  {
211  _TYPE_C vr;
212  for (int i = 0; i < _IQTY; i++)
213  {
214  vr.RefElem(i) = GetElem(i) * v2.GetElem(i);
215  }
216  return vr;
217  }
218  inline _TYPE_C GetDiv(const THIS_t& v2) const
219  {
223  _TYPE_C vr;
224  for (int i = 0; i < _IQTY; i++)
225  {
226  vr.RefElem(i) = GetElem(i) / v2.GetElem(i);
227  }
228  return vr;
229  }
230 #if 0
231  inline _TYPE_C operator * (const THIS_t& v2) const
232  {
234  return GetMul(v2);
235  }
236  inline _TYPE_C operator / (const THIS_t& v2) const
237  {
239  return GetDiv(v2);
240  }
241 #endif
242 
243  TYPE GetDistSq(const THIS_t& v2) const
244  {
246  _TYPE_C vd = GetDiff(v2);
247  return vd.get_MagnitudeSq();
248  }
249  TYPE GetDist(const THIS_t& v2) const
250  {
252  return Calc::Sqrt(GetDistSq(v2));
253  }
254 
255  inline TYPE GetDot(const THIS_t& v2) const
256  {
264  TYPE nMagnitude = 0;
265  for (int i = 0; i < _IQTY; i++)
266  {
267  nMagnitude += GetElem(i) * v2.GetElem(i);
268  }
269  return nMagnitude;
270  }
271  static inline TYPE GetDot(const THIS_t& v1, const THIS_t& v2)
272  {
273  return v1.GetDot(v2);
274  }
275 #if 0
276  inline TYPE operator*(const THIS_t& v2) const
277  {
279  return GetDot(v2);
280  }
281 #endif
282 
283  inline _TYPE_C get_Normalized() const
284  {
286  _TYPE_C vr;
287  TYPE nLength = get_Magnitude();
288  if (nLength)
289  {
290  for (int i = 0; i < _IQTY; i++)
291  {
292  vr.RefElem(i) = GetElem(i) / nLength;
293  }
294  }
295  else
296  {
297  vr.SetZero();
298  }
299  // ASSERT( Calc::IsNear( get_Magnitude(), 1 ));
300  return vr;
301  }
302 
303  // Setters
304  operator TYPE*()
305  {
308  return (TYPE*) this;
309  }
310  TYPE& RefElem(int i) noexcept
311  {
313  DEBUG_CHECK(IS_INDEX_GOOD(i, _IQTY));
314  return ((TYPE*) this)[i];
315  }
316  inline TYPE& operator[] (int i)
317  {
318  // just so there is no confusion with auto generated TYPE* []
319  return RefElem(i);
320  }
321 
322  void Set(const THIS_t& v)
323  {
324  ::memcpy(this, &v, sizeof(TYPE) * _IQTY);
325  }
326 
327  void SetZero() noexcept
328  {
331  cMem::Zero(this, sizeof(TYPE)*_IQTY);
332  }
333 
334  TYPE SetNormalized(void) noexcept
335  {
338  TYPE nLength = get_Magnitude();
339  if (nLength != 0)
340  {
341  DoScale(((TYPE)1) / nLength);
342  // ASSERT( get_Magnitude() == 1 );
343  }
344  else
345  {
346  SetZero(); // or do nothing ??
347  }
348  return nLength;
349  }
350  bool put_Magnitude(TYPE nLength)
351  {
353  TYPE nLengthOld = get_Magnitude();
354  if (nLengthOld == 0)
355  return false;
356  DoScale(nLength / nLengthOld);
357  // ASSERT( get_Magnitude() == nLength );
358  return true;
359  }
360  inline void SetLerp(const THIS_t& a, const THIS_t& b, DVALUE_t t)
361  {
364  for (int i = 0; i < _IQTY; i++)
365  {
366  RefElem(i) = Calc::Lerp(a.GetElem(i), b.GetElem(i), t);
367  }
368  }
369 
370  // change ops
371 
372  const _TYPE_C& operator += (const THIS_t& v2)
373  {
374  for (int i = 0; i < _IQTY; i++)
375  {
376  RefElem(i) += v2.GetElem(i);
377  }
378  return *((_TYPE_C*)this);
379  }
380  const _TYPE_C& operator += (TYPE n)
381  {
382  for (int i = 0; i < _IQTY; i++)
383  {
384  RefElem(i) += n;
385  }
386  return *((_TYPE_C*)this);
387  }
388  const _TYPE_C& operator -= (const THIS_t& v2) noexcept
389  {
390  for (int i = 0; i < _IQTY; i++)
391  {
392  RefElem(i) -= v2.GetElem(i);
393  }
394  return *((_TYPE_C*)this);
395  }
396  const _TYPE_C& operator -= (TYPE n) noexcept
397  {
398  for (int i = 0; i < _IQTY; i++)
399  {
400  RefElem(i) -= n;
401  }
402  return *((_TYPE_C*)this);
403  }
404  void DoScale(TYPE n) noexcept
405  {
407  for (int i = 0; i < _IQTY; i++)
408  {
409  RefElem(i) *= n;
410  }
411  }
412  const _TYPE_C& operator *= (TYPE nScale) noexcept
413  {
414  DoScale(nScale);
415  return *((_TYPE_C*)this);
416  }
417  const _TYPE_C& operator /= (TYPE nScale)
418  {
419  ASSERT(nScale);
420  DoScale(((TYPE)1) / nScale);
421  return *((_TYPE_C*)this);
422  }
423  void DoMul(const THIS_t& v2) noexcept
424  {
427  for (int i = 0; i < _IQTY; i++)
428  {
429  RefElem(i) *= v2.GetElem(i);
430  }
431  }
432  _TYPE_C& operator *= (const THIS_t& v2) noexcept
433  {
435  DoMul(v2);
436  return *((_TYPE_C*)this);
437  }
438  void DoDiv(const THIS_t& v2)
439  {
440  for (int i = 0; i < _IQTY; i++)
441  {
442  RefElem(i) /= v2.GetElem(i);
443  }
444  }
445  _TYPE_C& operator /= (const THIS_t& v2)
446  {
448  DoDiv(v2);
449  return *((_TYPE_C*)this);
450  }
451 
452  protected:
453  cVecTC() // only used as a base class. may have undefined/uninit data.
454  {}
455  };
456 
457  template<typename TYPE, int _IQTY>
458  class GRAYLIB_LINK cVecT : public cVecTC<TYPE, _IQTY, cVecT<TYPE, _IQTY> >
459  {
461  typedef cVecT<TYPE, _IQTY> THIS_t;
463  public:
464  TYPE m_a[_IQTY];
465  };
466 
467 #ifdef _MSC_VER
468 #pragma warning(disable:4201) // nonstandard extension used : nameless struct / union
469 #endif
470 
471  template<typename TYPE = DVALUEDEF_t>
472  class GRAYLIB_LINK cVecT2 : public cVecTC<TYPE, 2, cVecT2<TYPE> >
473  {
481 
482  public:
485 
486  union
487  {
488  TYPE m_a[k_nDim];
489  struct { TYPE m_x, m_y; };
490  struct { TYPE x, y; };
491  };
492 
493  cVecT2() noexcept
494  {
496  }
497  cVecT2(const SUPER_t& v) noexcept
498  {
499  ::memcpy(m_a, &v, sizeof(m_a));
500  }
501  cVecT2(const TYPE* pVals)
502  {
503  ::memcpy(m_a, pVals, sizeof(m_a));
504  }
505  cVecT2(TYPE n0, TYPE n1) noexcept
506  : m_x(n0), m_y(n1)
507  {
508  }
509 
510  const TYPE& get_X() const noexcept
511  {
512  return m_x;
513  }
514  const TYPE& get_Y() const noexcept
515  {
516  return m_y;
517  }
518  };
519  typedef cVecT2<float> cFloat2; // same as HLSL float2
520 
521  template <typename TYPE>
522  inline cVecT2<TYPE> operator*(const TYPE nVal, const cVecT2<TYPE>& v2)
523  {
525  return v2*nVal;
526  }
527 
528  template<typename TYPE = DVALUEDEF_t>
529  class GRAYLIB_LINK cVecT3 : public cVecTC<TYPE, 3, cVecT3<TYPE> >
530  {
536 
537  public:
540 
541  union
542  {
543  TYPE m_a[k_nDim];
544  struct { TYPE m_x, m_y, m_z; }; // point
545  struct { TYPE x, y, z; }; // vector
546  struct { TYPE r, g, b; }; // color (no alpha)
547  // struct { cVecT2<TYPE> m_v2; TYPE m_vz; };
548  };
549 
550  cVecT3() noexcept
551  {
553  }
554  cVecT3(const SUPER_t& v) noexcept
555  {
556  ::memcpy(m_a, &v, sizeof(m_a));
557  }
558  cVecT3(const TYPE* pVals) noexcept
559  {
560  if (pVals == nullptr)
561  return;
562  ::memcpy(m_a, pVals, sizeof(m_a));
563  }
564  cVecT3(TYPE n0, TYPE n1, TYPE n2 = 0) noexcept
565  : m_x(n0), m_y(n1), m_z(n2)
566  {
567  }
568 
569  TYPE get_X() const noexcept
570  {
571  return m_x;
572  }
573  TYPE get_Y() const noexcept
574  {
575  return m_y;
576  }
577  TYPE get_Z() const noexcept
578  {
579  return m_z;
580  }
581 
582  const cVecT2<TYPE>& get_V2() const noexcept
583  {
586  return *reinterpret_cast<const cVecT2<TYPE>*>(m_a);
587  }
588  bool IsSame2D(const THIS_t& pt) const noexcept
589  {
590  return m_x == pt.m_x && m_y == pt.m_y;
591  }
592 
593  TYPE GetDist2DSq(TYPE nX, TYPE nY) const
594  {
595  TYPE dx = nX - m_x;
596  TYPE dy = nY - m_y;
597  return(Calc::Sqr(dx) + Calc::Sqr(dy));
598  }
599  TYPE GetDist2DSq(const THIS_t& pt) const
600  {
601  TYPE dx = pt.m_x - m_x;
602  TYPE dy = pt.m_y - m_y;
603  return(Calc::Sqr(dx) + Calc::Sqr(dy));
604  }
605 
606  TYPE GetDist2D(const THIS_t& pt) const // 2D Distance between points
607  {
608  return(Calc::Sqrt(GetDist2DSq(pt.m_x, pt.m_y)));
609  }
610 
611  inline void InitCross(const THIS_t& rA, const THIS_t& rB)
612  {
615  ASSERT(this != &rA);
616  ASSERT(this != &rB);
617  this->m_x = (rA.m_y * rB.m_z) - (rA.m_z * rB.m_y);
618  this->m_y = (rA.m_z * rB.m_x) - (rA.m_x * rB.m_z);
619  this->m_z = (rA.m_x * rB.m_y) - (rA.m_y * rB.m_x);
620  }
621  inline THIS_t GetCross(const THIS_t& rB) const
622  {
625  THIS_t vRet;
626  vRet.InitCross(*this, rB);
627  return vRet;
628  }
629  static inline THIS_t GetCross(const THIS_t& rA, const THIS_t& rB)
630  {
633  THIS_t vRet;
634  vRet.InitCross(rA, rB);
635  return vRet;
636  }
637 #if 0
638  inline THIS_t operator^(const THIS_t& v2) const
639  {
641  return GetCross(v2);
642  }
643 #endif
644 
645  void SetCross(const THIS_t& v2)
646  {
648  THIS_t oThis = *this;
649  InitCross(oThis, v2);
650  }
651  };
652  typedef cVecT3<float> cFloat3; // same as HLSL float3
653 
654  template <typename TYPE>
655  inline cVecT3<TYPE> operator*(const TYPE nVal, const cVecT3<TYPE>& v2)
656  {
658  return (v2*nVal);
659  }
660 
661  template<typename TYPE = DVALUEDEF_t>
662  class GRAYLIB_LINK cVecT4 : public cVecTC<TYPE, 4, cVecT4<TYPE> >
663  {
668 
669  typedef cVecT4<TYPE> THIS_t;
671  public:
672  union
673  {
674  TYPE m_a[4];
675  struct { TYPE m_x, m_y, m_z, m_w; }; // quaternion.
676  struct { TYPE x, y, z, w; }; // quaternion.
677  struct { TYPE r, g, b, a; }; // color D3DXCOLOR, cColorf
678  // struct { TYPE a,b,c,d; }; // plane
679  // struct { cVecT3<TYPE> m_v3; TYPE m_vw; }; // vector3d + distance = ray.
680  };
681 
682  cVecT4() noexcept
683  {
685  }
686  cVecT4(const SUPER_t& v) noexcept
687  {
688  ::memcpy(m_a, &v, sizeof(m_a));
689  }
690  cVecT4(const TYPE* pVals) noexcept
691  {
692  if (pVals == nullptr)
693  return;
694  ::memcpy(m_a, pVals, sizeof(m_a));
695  }
696  cVecT4(TYPE n0, TYPE n1, TYPE n2 = 0, TYPE n3 = 0) noexcept
697  : m_x(n0), m_y(n1), m_z(n2), m_w(n3)
698  {
699  }
700  cVecT4(const cVecT3<TYPE>& v2, TYPE _w = 0)
701  : m_x(v2.GetElem(0)), m_y(v2.GetElem(1)), m_z(v2.GetElem(2)), m_w(_w)
702  {
703  }
704 
705  const TYPE& get_X() const noexcept
706  {
707  return m_x;
708  }
709  const TYPE& get_Y() const noexcept
710  {
711  return m_y;
712  }
713  const TYPE& get_Z() const noexcept
714  {
715  return m_z;
716  }
717  const TYPE& get_W() const noexcept
718  {
719  return m_w;
720  }
721 
722  const cVecT3<TYPE>& get_V3() const noexcept
723  {
725  return *reinterpret_cast<const cVecT3<TYPE>*>(m_a);
726  }
727  cVecT3<TYPE>& ref_V3() noexcept
728  {
730  return *reinterpret_cast<cVecT3<TYPE>*>(m_a);
731  }
732 
733  inline void InitCross(const THIS_t& v1, const THIS_t& v2, const THIS_t& v3)
734  {
736  this->x = v1.y * (v2.z * v3.w - v3.z * v2.w) - v1.z * (v2.y * v3.w - v3.y * v2.w) + v1.w * (v2.y * v3.z - v2.z *v3.y);
737  this->y = -(v1.x * (v2.z * v3.w - v3.z * v2.w) - v1.z * (v2.x * v3.w - v3.x * v2.w) + v1.w * (v2.x * v3.z - v3.x * v2.z));
738  this->z = v1.x * (v2.y * v3.w - v3.y * v2.w) - v1.y * (v2.x *v3.w - v3.x * v2.w) + v1.w * (v2.x * v3.y - v3.x * v2.y);
739  this->w = -(v1.x * (v2.y * v3.z - v3.y * v2.z) - v1.y * (v2.x * v3.z - v3.x *v2.z) + v1.z * (v2.x * v3.y - v3.x * v2.y));
740  }
741  };
742  typedef cVecT4<float> cFloat4; // same as HLSL float4.
743 
744  template <typename TYPE>
745  inline cVecT4<TYPE> operator*(const TYPE nVal, const cVecT4<TYPE>& v2)
746  {
748  return (v2*nVal);
749  }
750 
751 #ifdef GRAY_DLL // force implementation/instantiate for DLL/SO.
752  template class GRAYLIB_LINK cVecT2<float>;
753  template class GRAYLIB_LINK cVecTC<float, 2, cVecT2<float> >;
754  template class GRAYLIB_LINK cVecT3<float>;
755  template class GRAYLIB_LINK cVecTC<float, 3, cVecT3<float> >;
756  template class GRAYLIB_LINK cVecT4<float>;
757  template class GRAYLIB_LINK cVecTC<float, 4, cVecT4<float> >;
758 
759  template class GRAYLIB_LINK cVecT3<int>;
760  template class GRAYLIB_LINK cVecTC<int, 2, cVecT2<int> >;
761 
762  template class GRAYLIB_LINK cVecT2<double>;
763  template class GRAYLIB_LINK cVecTC<double, 2, cVecT2<double> >;
764  template class GRAYLIB_LINK cVecT3<double>;
765  template class GRAYLIB_LINK cVecTC<double, 3, cVecT3<double> >;
766 #endif
767 
768 };
769 
770 #endif // _INC_cVecT_H
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
#define IS_INDEX_GOOD(i, q)
cast the (likely) int to unsigned to check for negatives.
Definition: Index.h:35
Using X files without the sources and the makefile How to use you just create a debug directory e g
Definition: Readme.txt:21
#define TYPE
Definition: StrT.cpp:38
#define ASSERT(exp)
Definition: cDebugAssert.h:87
#define DEBUG_CHECK(exp)
Definition: cDebugAssert.h:90
Definition: cVecT.h:473
cVecT2(const TYPE *pVals)
Definition: cVecT.h:501
cVecT2() noexcept
Definition: cVecT.h:493
TYPE x
Definition: cVecT.h:490
cVecTC< TYPE, k_nDim, THIS_t > SUPER_t
Definition: cVecT.h:484
TYPE m_x
Definition: cVecT.h:489
const TYPE & get_X() const noexcept
Definition: cVecT.h:510
const TYPE & get_Y() const noexcept
Definition: cVecT.h:514
cVecT2(const SUPER_t &v) noexcept
Definition: cVecT.h:497
cVecT2(TYPE n0, TYPE n1) noexcept
Definition: cVecT.h:505
cVecT2< TYPE > THIS_t
Definition: cVecT.h:483
Definition: cVecT.h:530
cVecT3(const TYPE *pVals) noexcept
Definition: cVecT.h:558
TYPE get_Z() const noexcept
Definition: cVecT.h:577
cVecT3(TYPE n0, TYPE n1, TYPE n2=0) noexcept
Definition: cVecT.h:564
TYPE GetDist2D(const THIS_t &pt) const
Definition: cVecT.h:606
void InitCross(const THIS_t &rA, const THIS_t &rB)
Definition: cVecT.h:611
THIS_t GetCross(const THIS_t &rB) const
Definition: cVecT.h:621
const cVecT2< TYPE > & get_V2() const noexcept
Definition: cVecT.h:582
cVecT3(const SUPER_t &v) noexcept
Definition: cVecT.h:554
cVecT3< TYPE > THIS_t
Definition: cVecT.h:538
TYPE m_z
Definition: cVecT.h:544
bool IsSame2D(const THIS_t &pt) const noexcept
Definition: cVecT.h:588
cVecTC< TYPE, k_nDim, THIS_t > SUPER_t
Definition: cVecT.h:539
TYPE GetDist2DSq(const THIS_t &pt) const
Definition: cVecT.h:599
TYPE m_x
Definition: cVecT.h:544
cVecT3() noexcept
Definition: cVecT.h:550
TYPE GetDist2DSq(TYPE nX, TYPE nY) const
Definition: cVecT.h:593
TYPE b
Definition: cVecT.h:546
static THIS_t GetCross(const THIS_t &rA, const THIS_t &rB)
Definition: cVecT.h:629
TYPE m_y
Definition: cVecT.h:544
TYPE get_X() const noexcept
Definition: cVecT.h:569
TYPE x
Definition: cVecT.h:545
void SetCross(const THIS_t &v2)
Definition: cVecT.h:645
TYPE get_Y() const noexcept
Definition: cVecT.h:573
Definition: cVecT.h:663
TYPE m_w
Definition: cVecT.h:675
const TYPE & get_X() const noexcept
Definition: cVecT.h:705
TYPE z
Definition: cVecT.h:676
cVecT3< TYPE > & ref_V3() noexcept
Definition: cVecT.h:727
cVecT4(const TYPE *pVals) noexcept
Definition: cVecT.h:690
const TYPE & get_Z() const noexcept
Definition: cVecT.h:713
TYPE x
Definition: cVecT.h:676
cVecT4(const SUPER_t &v) noexcept
Definition: cVecT.h:686
void InitCross(const THIS_t &v1, const THIS_t &v2, const THIS_t &v3)
Definition: cVecT.h:733
TYPE a
Definition: cVecT.h:677
TYPE w
Definition: cVecT.h:676
const TYPE & get_Y() const noexcept
Definition: cVecT.h:709
const cVecT3< TYPE > & get_V3() const noexcept
Definition: cVecT.h:722
cVecT4(const cVecT3< TYPE > &v2, TYPE _w=0)
Definition: cVecT.h:700
cVecT4() noexcept
Definition: cVecT.h:682
TYPE y
Definition: cVecT.h:676
const TYPE & get_W() const noexcept
Definition: cVecT.h:717
cVecT4(TYPE n0, TYPE n1, TYPE n2=0, TYPE n3=0) noexcept
Definition: cVecT.h:696
default type for DVALUE_t in templates
Definition: cVecT.h:38
TYPE get_Magnitude() const noexcept
Definition: cVecT.h:129
void DoMul(const THIS_t &v2) noexcept
Definition: cVecT.h:423
bool isZero() const noexcept
Definition: cVecT.h:84
const _TYPE_C & get_CR() const noexcept
Definition: cVecT.h:59
COMPARE_t Compare(const THIS_t &v2) const noexcept
Definition: cVecT.h:95
_TYPE_C GetDiff(const THIS_t &v2) const
Definition: cVecT.h:170
TYPE GetDistSq(const THIS_t &v2) const
Definition: cVecT.h:243
static TYPE GetDot(const THIS_t &v1, const THIS_t &v2)
Definition: cVecT.h:271
TYPE GetElem(int i) const noexcept
Definition: cVecT.h:70
TYPE get_MagnitudeSq() const noexcept
Definition: cVecT.h:118
cVecTC< TYPE, _IQTY, _TYPE_C > THIS_t
Definition: cVecT.h:49
_TYPE_C GetDiv(const THIS_t &v2) const
Definition: cVecT.h:218
TYPE DVALUE_t
Dimension value type.
Definition: cVecT.h:48
void Set(const THIS_t &v)
Definition: cVecT.h:322
TYPE SetNormalized(void) noexcept
Definition: cVecT.h:334
_TYPE_C GetSum(const THIS_t &v2) const
Definition: cVecT.h:155
TYPE * get_T() noexcept
Definition: cVecT.h:51
const TYPE * get_CT() const noexcept
Definition: cVecT.h:55
TYPE & RefElem(int i) noexcept
Definition: cVecT.h:310
void SetLerp(const THIS_t &a, const THIS_t &b, DVALUE_t t)
Definition: cVecT.h:360
void SetZero() noexcept
Definition: cVecT.h:327
cVecTC()
Definition: cVecT.h:453
bool put_Magnitude(TYPE nLength)
Definition: cVecT.h:350
_TYPE_C get_Abs() const
Definition: cVecT.h:146
void DoDiv(const THIS_t &v2)
Definition: cVecT.h:438
_TYPE_C GetScaled(TYPE nScale) const
Definition: cVecT.h:184
_TYPE_C get_Normalized() const
Definition: cVecT.h:283
void DoScale(TYPE n) noexcept
Definition: cVecT.h:404
TYPE GetDot(const THIS_t &v2) const
Definition: cVecT.h:255
bool IsNear(const THIS_t &v2, TYPE fDist=(TYPE) k_FLT_MIN2) const
Definition: cVecT.h:108
_TYPE_C GetMul(const THIS_t &v2) const
Definition: cVecT.h:205
TYPE GetDist(const THIS_t &v2) const
Definition: cVecT.h:249
Definition: cVecT.h:459
Definition: cMesh.h:22
cVecT2< TYPE > operator*(const TYPE nVal, const cVecT2< TYPE > &v2)
Definition: cVecT.h:522
float DVALUEDEF_t
similar to D3DVALUE in DX. the basic default dimension type. DVALUEDEF_t
Definition: cVecT.h:34
cVecT2< float > cFloat2
Definition: cVecT.h:519
cVecT4< float > cFloat4
Definition: cVecT.h:742
cVecT3< float > cFloat3
Definition: cVecT.h:652
GINTERSECT_TYPE
Definition: cVecT.h:20
@ GINTERSECT_In2
object1 fully inside object2.
Definition: cVecT.h:29
@ GINTERSECT_Error
Error or Not init.
Definition: cVecT.h:30
@ GINTERSECT_In1
object2 fully inside (or equal to) object1 (the main search comparator). CONTAINS
Definition: cVecT.h:28
@ GINTERSECT_Partial
object2 partly inside object1. partial intersection. INTERSECTS
Definition: cVecT.h:27
@ GINTERSECT_None
object2 completely outside object1 (no intersection) DISJOINT
Definition: cVecT.h:26
int COMPARE_t
result of compare. 0=same, 1=a>b, -1=a<b
Definition: cValT.h:17
cUInt64 operator^(const cUInt64 &roUI64_1, const cUInt64 &roUI64_2)
Definition: cUInt64.h:391
cStringA operator+(const char *pStr1, const cStringA &s2)
Definition: cString.h:642
bool operator!=(const cTimeDouble &dt1, const cTimeDouble &dt2)
Definition: cTimeDouble.h:254
bool operator==(const cTimeDouble &dt1, const cTimeDouble &dt2)
Definition: cTimeDouble.h:250
static TYPE Abs(TYPE a) noexcept
similar to ABS(n) macro. Does nothing for unsigned types.
static bool IsNear(TYPE n1, TYPE n2, TYPE nDiff=(TYPE) k_FLT_MIN2) noexcept
Definition: Calc.h:135
static TYPE Sqr(TYPE a) noexcept
Definition: Calc.h:141
static TYPE Sqrt(TYPE a)
Definition: Calc.h:430
static TYPE Lerp(TYPE nVal1, TYPE nVal2, TYPE fRatio) noexcept
Definition: Calc.h:400
static void Zero(void *pData, size_t nSizeBlock) noexcept
Definition: cMem.h:100