HatchitMath
ht_vector4.h
1 
25 #pragma once
26 
27 #include <ht_platform.h>
28 #include <iostream>
29 #include <ostream>
30 #include <ht_scalar.h>
31 
32 namespace Hatchit
33 {
34  namespace Math
35  {
36  class Vector2;
37  class Vector3;
38 
39  class HT_API Vector4
40  {
41  friend class Matrix4;
42  friend class Quaternion;
43 
44  public:
45  //Constructors
47  Vector4();
49  Vector4(float x, float y, float z, float w);
51  Vector4(const Vector4& other);
53  Vector4(Vector3& v3, float w);
54 
55  //Custom allocation/deallocation
57  void* operator new(size_t _size);
59  void operator delete(void* p);
61  operator const __m128(void) const;
62 
63 
64  float magSqr();
65 
69  float mag();
70 
71 
76  Vector4 normalized();
77 
78 
82  float* getAsArray();
83 
84 
85  //Static functions
86 
92  static float Dot(Vector4 v, Vector4 u);
93 
94  //Operators
95 
101  Vector4 operator* (float s);
107  Vector4 operator/ (float s);
113  Vector4 operator- (float s);
119  Vector4 operator+ (float s);
120 
126  Vector4 operator*= (float s);
132  Vector4 operator/= (float s);
138  Vector4 operator-= (float s);
144  Vector4 operator+= (float s);
145 
150  bool operator>(Vector4 u);
155  bool operator<(Vector4 u);
160  bool operator==(Vector4 u);
165  bool operator!=(Vector4 u);
166 
171  float operator* (Vector4 u);
172 
177  Vector4 operator+ (Vector4 u);
182  Vector4 operator- (Vector4 u);
187  Vector4 operator+= (Vector4 u);
192  Vector4 operator-= (Vector4 u);
193 
199  float& operator[] (int i);
200 
202  operator Vector3();
204  operator Vector2();
205 
206  public:
207  union
208  {
209  __m128 m_vector;
210  struct
211  {
212  float x, y, z, w;
213  };
214  float data[4];
215  };
216  };
217 
222  HT_API std::ostream& operator<< (std::ostream& output, Vector4& h);
227  HT_API std::istream& operator>> (std::istream& input, Vector4& h);
228  }
229 }
Hatchit Engine Copyright(c) 2015 Third-Degree.
Hatchit Engine Copyright(c) 2015-2016 Third-Degree.
Definition: ht_intrin.h:33
Hatchit Engine Copyright(c) 2015 Third-Degree.
Hatchit Engine Copyright(c) 2015 Third-Degree.
Hatchit Engine Copyright(c) 2015 Third-Degree.
Hatchit Engine Copyright(c) 2015 Third-Degree.