IcePoint.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. /**
  3. * Contains code for 3D vectors.
  4. * \file IcePoint.h
  5. * \author Pierre Terdiman
  6. * \date April, 4, 2000
  7. */
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  10. // Include Guard
  11. #ifndef __ICEPOINT_H__
  12. #define __ICEPOINT_H__
  13. // Forward declarations
  14. class HPoint;
  15. class Plane;
  16. class Matrix3x3;
  17. class Matrix4x4;
  18. #define CROSS2D(a, b) (a.x*b.y - b.x*a.y)
  19. const float EPSILON2 = 1.0e-20f;
  20. class ICEMATHS_API Point
  21. {
  22. public:
  23. //! Empty constructor
  24. inline_ Point() {}
  25. //! Constructor from a single float
  26. // inline_ Point(float val) : x(val), y(val), z(val) {}
  27. // Removed since it introduced the nasty "Point T = *Matrix4x4.GetTrans();" bug.......
  28. //! Constructor from floats
  29. inline_ Point(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
  30. //! Constructor from array
  31. inline_ Point(const float f[3]) : x(f[_X]), y(f[_Y]), z(f[_Z]) {}
  32. //! Copy constructor
  33. inline_ Point(const Point& p) : x(p.x), y(p.y), z(p.z) {}
  34. //! Destructor
  35. inline_ ~Point() {}
  36. //! Clears the vector
  37. inline_ Point& Zero() { x = y = z = 0.0f; return *this; }
  38. //! + infinity
  39. inline_ Point& SetPlusInfinity() { x = y = z = MAX_FLOAT; return *this; }
  40. //! - infinity
  41. inline_ Point& SetMinusInfinity() { x = y = z = MIN_FLOAT; return *this; }
  42. //! Sets positive unit random vector
  43. Point& PositiveUnitRandomVector();
  44. //! Sets unit random vector
  45. Point& UnitRandomVector();
  46. //! Assignment from values
  47. inline_ Point& Set(float _x, float _y, float _z) { x = _x; y = _y; z = _z; return *this; }
  48. //! Assignment from array
  49. inline_ Point& Set(const float f[3]) { x = f[_X]; y = f[_Y]; z = f[_Z]; return *this; }
  50. //! Assignment from another point
  51. inline_ Point& Set(const Point& src) { x = src.x; y = src.y; z = src.z; return *this; }
  52. //! Adds a vector
  53. inline_ Point& Add(const Point& p) { x += p.x; y += p.y; z += p.z; return *this; }
  54. //! Adds a vector
  55. inline_ Point& Add(float _x, float _y, float _z) { x += _x; y += _y; z += _z; return *this; }
  56. //! Adds a vector
  57. inline_ Point& Add(const float f[3]) { x += f[_X]; y += f[_Y]; z += f[_Z]; return *this; }
  58. //! Adds vectors
  59. inline_ Point& Add(const Point& p, const Point& q) { x = p.x+q.x; y = p.y+q.y; z = p.z+q.z; return *this; }
  60. //! Subtracts a vector
  61. inline_ Point& Sub(const Point& p) { x -= p.x; y -= p.y; z -= p.z; return *this; }
  62. //! Subtracts a vector
  63. inline_ Point& Sub(float _x, float _y, float _z) { x -= _x; y -= _y; z -= _z; return *this; }
  64. //! Subtracts a vector
  65. inline_ Point& Sub(const float f[3]) { x -= f[_X]; y -= f[_Y]; z -= f[_Z]; return *this; }
  66. //! Subtracts vectors
  67. inline_ Point& Sub(const Point& p, const Point& q) { x = p.x-q.x; y = p.y-q.y; z = p.z-q.z; return *this; }
  68. //! this = -this
  69. inline_ Point& Neg() { x = -x; y = -y; z = -z; return *this; }
  70. //! this = -a
  71. inline_ Point& Neg(const Point& a) { x = -a.x; y = -a.y; z = -a.z; return *this; }
  72. //! Multiplies by a scalar
  73. inline_ Point& Mult(float s) { x *= s; y *= s; z *= s; return *this; }
  74. //! this = a * scalar
  75. inline_ Point& Mult(const Point& a, float scalar)
  76. {
  77. x = a.x * scalar;
  78. y = a.y * scalar;
  79. z = a.z * scalar;
  80. return *this;
  81. }
  82. //! this = a + b * scalar
  83. inline_ Point& Mac(const Point& a, const Point& b, float scalar)
  84. {
  85. x = a.x + b.x * scalar;
  86. y = a.y + b.y * scalar;
  87. z = a.z + b.z * scalar;
  88. return *this;
  89. }
  90. //! this = this + a * scalar
  91. inline_ Point& Mac(const Point& a, float scalar)
  92. {
  93. x += a.x * scalar;
  94. y += a.y * scalar;
  95. z += a.z * scalar;
  96. return *this;
  97. }
  98. //! this = a - b * scalar
  99. inline_ Point& Msc(const Point& a, const Point& b, float scalar)
  100. {
  101. x = a.x - b.x * scalar;
  102. y = a.y - b.y * scalar;
  103. z = a.z - b.z * scalar;
  104. return *this;
  105. }
  106. //! this = this - a * scalar
  107. inline_ Point& Msc(const Point& a, float scalar)
  108. {
  109. x -= a.x * scalar;
  110. y -= a.y * scalar;
  111. z -= a.z * scalar;
  112. return *this;
  113. }
  114. //! this = a + b * scalarb + c * scalarc
  115. inline_ Point& Mac2(const Point& a, const Point& b, float scalarb, const Point& c, float scalarc)
  116. {
  117. x = a.x + b.x * scalarb + c.x * scalarc;
  118. y = a.y + b.y * scalarb + c.y * scalarc;
  119. z = a.z + b.z * scalarb + c.z * scalarc;
  120. return *this;
  121. }
  122. //! this = a - b * scalarb - c * scalarc
  123. inline_ Point& Msc2(const Point& a, const Point& b, float scalarb, const Point& c, float scalarc)
  124. {
  125. x = a.x - b.x * scalarb - c.x * scalarc;
  126. y = a.y - b.y * scalarb - c.y * scalarc;
  127. z = a.z - b.z * scalarb - c.z * scalarc;
  128. return *this;
  129. }
  130. //! this = mat * a
  131. inline_ Point& Mult(const Matrix3x3& mat, const Point& a);
  132. //! this = mat1 * a1 + mat2 * a2
  133. inline_ Point& Mult2(const Matrix3x3& mat1, const Point& a1, const Matrix3x3& mat2, const Point& a2);
  134. //! this = this + mat * a
  135. inline_ Point& Mac(const Matrix3x3& mat, const Point& a);
  136. //! this = transpose(mat) * a
  137. inline_ Point& TransMult(const Matrix3x3& mat, const Point& a);
  138. //! Linear interpolate between two vectors: this = a + t * (b - a)
  139. inline_ Point& Lerp(const Point& a, const Point& b, float t)
  140. {
  141. x = a.x + t * (b.x - a.x);
  142. y = a.y + t * (b.y - a.y);
  143. z = a.z + t * (b.z - a.z);
  144. return *this;
  145. }
  146. //! Hermite interpolate between p1 and p2. p0 and p3 are used for finding gradient at p1 and p2.
  147. //! this = p0 * (2t^2 - t^3 - t)/2
  148. //! + p1 * (3t^3 - 5t^2 + 2)/2
  149. //! + p2 * (4t^2 - 3t^3 + t)/2
  150. //! + p3 * (t^3 - t^2)/2
  151. inline_ Point& Herp(const Point& p0, const Point& p1, const Point& p2, const Point& p3, float t)
  152. {
  153. float t2 = t * t;
  154. float t3 = t2 * t;
  155. float kp0 = (2.0f * t2 - t3 - t) * 0.5f;
  156. float kp1 = (3.0f * t3 - 5.0f * t2 + 2.0f) * 0.5f;
  157. float kp2 = (4.0f * t2 - 3.0f * t3 + t) * 0.5f;
  158. float kp3 = (t3 - t2) * 0.5f;
  159. x = p0.x * kp0 + p1.x * kp1 + p2.x * kp2 + p3.x * kp3;
  160. y = p0.y * kp0 + p1.y * kp1 + p2.y * kp2 + p3.y * kp3;
  161. z = p0.z * kp0 + p1.z * kp1 + p2.z * kp2 + p3.z * kp3;
  162. return *this;
  163. }
  164. //! this = rotpos * r + linpos
  165. inline_ Point& Transform(const Point& r, const Matrix3x3& rotpos, const Point& linpos);
  166. //! this = trans(rotpos) * (r - linpos)
  167. inline_ Point& InvTransform(const Point& r, const Matrix3x3& rotpos, const Point& linpos);
  168. //! Returns MIN(x, y, z);
  169. inline_ float Min() const { return MIN(x, MIN(y, z)); }
  170. //! Returns MAX(x, y, z);
  171. inline_ float Max() const { return MAX(x, MAX(y, z)); }
  172. //! Sets each element to be componentwise minimum
  173. inline_ Point& Min(const Point& p) { x = MIN(x, p.x); y = MIN(y, p.y); z = MIN(z, p.z); return *this; }
  174. //! Sets each element to be componentwise maximum
  175. inline_ Point& Max(const Point& p) { x = MAX(x, p.x); y = MAX(y, p.y); z = MAX(z, p.z); return *this; }
  176. //! Clamps each element
  177. inline_ Point& Clamp(float min, float max)
  178. {
  179. if(x<min) x=min; if(x>max) x=max;
  180. if(y<min) y=min; if(y>max) y=max;
  181. if(z<min) z=min; if(z>max) z=max;
  182. return *this;
  183. }
  184. //! Computes square magnitude
  185. inline_ float SquareMagnitude() const { return x*x + y*y + z*z; }
  186. //! Computes magnitude
  187. inline_ float Magnitude() const { return sqrtf(x*x + y*y + z*z); }
  188. //! Computes volume
  189. inline_ float Volume() const { return x * y * z; }
  190. //! Checks the point is near zero
  191. inline_ bool ApproxZero() const { return SquareMagnitude() < EPSILON2; }
  192. //! Tests for exact zero vector
  193. inline_ BOOL IsZero() const
  194. {
  195. if(IR(x) || IR(y) || IR(z)) return FALSE;
  196. return TRUE;
  197. }
  198. //! Checks point validity
  199. inline_ BOOL IsValid() const
  200. {
  201. if(!IsValidFloat(x)) return FALSE;
  202. if(!IsValidFloat(y)) return FALSE;
  203. if(!IsValidFloat(z)) return FALSE;
  204. return TRUE;
  205. }
  206. //! Slighty moves the point
  207. void Tweak(udword coord_mask, udword tweak_mask)
  208. {
  209. if(coord_mask&1) { udword Dummy = IR(x); Dummy^=tweak_mask; x = FR(Dummy); }
  210. if(coord_mask&2) { udword Dummy = IR(y); Dummy^=tweak_mask; y = FR(Dummy); }
  211. if(coord_mask&4) { udword Dummy = IR(z); Dummy^=tweak_mask; z = FR(Dummy); }
  212. }
  213. #define TWEAKMASK 0x3fffff
  214. #define TWEAKNOTMASK ~TWEAKMASK
  215. //! Slighty moves the point out
  216. inline_ void TweakBigger()
  217. {
  218. udword Dummy = (IR(x)&TWEAKNOTMASK); if(!IS_NEGATIVE_FLOAT(x)) Dummy+=TWEAKMASK+1; x = FR(Dummy);
  219. Dummy = (IR(y)&TWEAKNOTMASK); if(!IS_NEGATIVE_FLOAT(y)) Dummy+=TWEAKMASK+1; y = FR(Dummy);
  220. Dummy = (IR(z)&TWEAKNOTMASK); if(!IS_NEGATIVE_FLOAT(z)) Dummy+=TWEAKMASK+1; z = FR(Dummy);
  221. }
  222. //! Slighty moves the point in
  223. inline_ void TweakSmaller()
  224. {
  225. udword Dummy = (IR(x)&TWEAKNOTMASK); if(IS_NEGATIVE_FLOAT(x)) Dummy+=TWEAKMASK+1; x = FR(Dummy);
  226. Dummy = (IR(y)&TWEAKNOTMASK); if(IS_NEGATIVE_FLOAT(y)) Dummy+=TWEAKMASK+1; y = FR(Dummy);
  227. Dummy = (IR(z)&TWEAKNOTMASK); if(IS_NEGATIVE_FLOAT(z)) Dummy+=TWEAKMASK+1; z = FR(Dummy);
  228. }
  229. //! Normalizes the vector
  230. inline_ Point& Normalize()
  231. {
  232. float M = x*x + y*y + z*z;
  233. if(M)
  234. {
  235. M = 1.0f / sqrtf(M);
  236. x *= M;
  237. y *= M;
  238. z *= M;
  239. }
  240. return *this;
  241. }
  242. //! Sets vector length
  243. inline_ Point& SetLength(float length)
  244. {
  245. float NewLength = length / Magnitude();
  246. x *= NewLength;
  247. y *= NewLength;
  248. z *= NewLength;
  249. return *this;
  250. }
  251. //! Clamps vector length
  252. inline_ Point& ClampLength(float limit_length)
  253. {
  254. if(limit_length>=0.0f) // Magnitude must be positive
  255. {
  256. float CurrentSquareLength = SquareMagnitude();
  257. if(CurrentSquareLength > limit_length * limit_length)
  258. {
  259. float Coeff = limit_length / sqrtf(CurrentSquareLength);
  260. x *= Coeff;
  261. y *= Coeff;
  262. z *= Coeff;
  263. }
  264. }
  265. return *this;
  266. }
  267. //! Computes distance to another point
  268. inline_ float Distance(const Point& b) const
  269. {
  270. return sqrtf((x - b.x)*(x - b.x) + (y - b.y)*(y - b.y) + (z - b.z)*(z - b.z));
  271. }
  272. //! Computes square distance to another point
  273. inline_ float SquareDistance(const Point& b) const
  274. {
  275. return ((x - b.x)*(x - b.x) + (y - b.y)*(y - b.y) + (z - b.z)*(z - b.z));
  276. }
  277. //! Dot product dp = this|a
  278. inline_ float Dot(const Point& p) const { return p.x * x + p.y * y + p.z * z; }
  279. //! Cross product this = a x b
  280. inline_ Point& Cross(const Point& a, const Point& b)
  281. {
  282. x = a.y * b.z - a.z * b.y;
  283. y = a.z * b.x - a.x * b.z;
  284. z = a.x * b.y - a.y * b.x;
  285. return *this;
  286. }
  287. //! Vector code ( bitmask = sign(z) | sign(y) | sign(x) )
  288. inline_ udword VectorCode() const
  289. {
  290. return (IR(x)>>31) | ((IR(y)&SIGN_BITMASK)>>30) | ((IR(z)&SIGN_BITMASK)>>29);
  291. }
  292. //! Returns largest axis
  293. inline_ PointComponent LargestAxis() const
  294. {
  295. const float* Vals = &x;
  296. PointComponent m = _X;
  297. if(Vals[_Y] > Vals[m]) m = _Y;
  298. if(Vals[_Z] > Vals[m]) m = _Z;
  299. return m;
  300. }
  301. //! Returns closest axis
  302. inline_ PointComponent ClosestAxis() const
  303. {
  304. const float* Vals = &x;
  305. PointComponent m = _X;
  306. if(AIR(Vals[_Y]) > AIR(Vals[m])) m = _Y;
  307. if(AIR(Vals[_Z]) > AIR(Vals[m])) m = _Z;
  308. return m;
  309. }
  310. //! Returns smallest axis
  311. inline_ PointComponent SmallestAxis() const
  312. {
  313. const float* Vals = &x;
  314. PointComponent m = _X;
  315. if(Vals[_Y] < Vals[m]) m = _Y;
  316. if(Vals[_Z] < Vals[m]) m = _Z;
  317. return m;
  318. }
  319. //! Refracts the point
  320. Point& Refract(const Point& eye, const Point& n, float refractindex, Point& refracted);
  321. //! Projects the point onto a plane
  322. Point& ProjectToPlane(const Plane& p);
  323. //! Projects the point onto the screen
  324. void ProjectToScreen(float halfrenderwidth, float halfrenderheight, const Matrix4x4& mat, HPoint& projected) const;
  325. //! Unfolds the point onto a plane according to edge(a,b)
  326. Point& Unfold(Plane& p, Point& a, Point& b);
  327. //! Hash function from Ville Miettinen
  328. inline_ udword GetHashValue() const
  329. {
  330. const udword* h = (const udword*)(this);
  331. udword f = (h[0]+h[1]*11-(h[2]*17)) & 0x7fffffff; // avoid problems with +-0
  332. return (f>>22)^(f>>12)^(f);
  333. }
  334. //! Stuff magic values in the point, marking it as explicitely not used.
  335. void SetNotUsed();
  336. //! Checks the point is marked as not used
  337. BOOL IsNotUsed() const;
  338. // Arithmetic operators
  339. //! Unary operator for Point Negate = - Point
  340. inline_ Point operator-() const { return Point(-x, -y, -z); }
  341. //! Operator for Point Plus = Point + Point.
  342. inline_ Point operator+(const Point& p) const { return Point(x + p.x, y + p.y, z + p.z); }
  343. //! Operator for Point Minus = Point - Point.
  344. inline_ Point operator-(const Point& p) const { return Point(x - p.x, y - p.y, z - p.z); }
  345. //! Operator for Point Mul = Point * Point.
  346. inline_ Point operator*(const Point& p) const { return Point(x * p.x, y * p.y, z * p.z); }
  347. //! Operator for Point Scale = Point * float.
  348. inline_ Point operator*(float s) const { return Point(x * s, y * s, z * s ); }
  349. //! Operator for Point Scale = float * Point.
  350. inline_ friend Point operator*(float s, const Point& p) { return Point(s * p.x, s * p.y, s * p.z); }
  351. //! Operator for Point Div = Point / Point.
  352. inline_ Point operator/(const Point& p) const { return Point(x / p.x, y / p.y, z / p.z); }
  353. //! Operator for Point Scale = Point / float.
  354. inline_ Point operator/(float s) const { s = 1.0f / s; return Point(x * s, y * s, z * s); }
  355. //! Operator for Point Scale = float / Point.
  356. inline_ friend Point operator/(float s, const Point& p) { return Point(s / p.x, s / p.y, s / p.z); }
  357. //! Operator for float DotProd = Point | Point.
  358. inline_ float operator|(const Point& p) const { return x*p.x + y*p.y + z*p.z; }
  359. //! Operator for Point VecProd = Point ^ Point.
  360. inline_ Point operator^(const Point& p) const
  361. {
  362. return Point(
  363. y * p.z - z * p.y,
  364. z * p.x - x * p.z,
  365. x * p.y - y * p.x );
  366. }
  367. //! Operator for Point += Point.
  368. inline_ Point& operator+=(const Point& p) { x += p.x; y += p.y; z += p.z; return *this; }
  369. //! Operator for Point += float.
  370. inline_ Point& operator+=(float s) { x += s; y += s; z += s; return *this; }
  371. //! Operator for Point -= Point.
  372. inline_ Point& operator-=(const Point& p) { x -= p.x; y -= p.y; z -= p.z; return *this; }
  373. //! Operator for Point -= float.
  374. inline_ Point& operator-=(float s) { x -= s; y -= s; z -= s; return *this; }
  375. //! Operator for Point *= Point.
  376. inline_ Point& operator*=(const Point& p) { x *= p.x; y *= p.y; z *= p.z; return *this; }
  377. //! Operator for Point *= float.
  378. inline_ Point& operator*=(float s) { x *= s; y *= s; z *= s; return *this; }
  379. //! Operator for Point /= Point.
  380. inline_ Point& operator/=(const Point& p) { x /= p.x; y /= p.y; z /= p.z; return *this; }
  381. //! Operator for Point /= float.
  382. inline_ Point& operator/=(float s) { s = 1.0f/s; x *= s; y *= s; z *= s; return *this; }
  383. // Logical operators
  384. //! Operator for "if(Point==Point)"
  385. inline_ bool operator==(const Point& p) const { return ( (IR(x)==IR(p.x))&&(IR(y)==IR(p.y))&&(IR(z)==IR(p.z))); }
  386. //! Operator for "if(Point!=Point)"
  387. inline_ bool operator!=(const Point& p) const { return ( (IR(x)!=IR(p.x))||(IR(y)!=IR(p.y))||(IR(z)!=IR(p.z))); }
  388. // Arithmetic operators
  389. //! Operator for Point Mul = Point * Matrix3x3.
  390. inline_ Point operator*(const Matrix3x3& mat) const
  391. {
  392. class ShadowMatrix3x3{ public: float m[3][3]; }; // To allow inlining
  393. const ShadowMatrix3x3* Mat = (const ShadowMatrix3x3*)&mat;
  394. return Point(
  395. x * Mat->m[0][0] + y * Mat->m[1][0] + z * Mat->m[2][0],
  396. x * Mat->m[0][1] + y * Mat->m[1][1] + z * Mat->m[2][1],
  397. x * Mat->m[0][2] + y * Mat->m[1][2] + z * Mat->m[2][2] );
  398. }
  399. //! Operator for Point Mul = Point * Matrix4x4.
  400. inline_ Point operator*(const Matrix4x4& mat) const
  401. {
  402. class ShadowMatrix4x4{ public: float m[4][4]; }; // To allow inlining
  403. const ShadowMatrix4x4* Mat = (const ShadowMatrix4x4*)&mat;
  404. return Point(
  405. x * Mat->m[0][0] + y * Mat->m[1][0] + z * Mat->m[2][0] + Mat->m[3][0],
  406. x * Mat->m[0][1] + y * Mat->m[1][1] + z * Mat->m[2][1] + Mat->m[3][1],
  407. x * Mat->m[0][2] + y * Mat->m[1][2] + z * Mat->m[2][2] + Mat->m[3][2]);
  408. }
  409. //! Operator for Point *= Matrix3x3.
  410. inline_ Point& operator*=(const Matrix3x3& mat)
  411. {
  412. class ShadowMatrix3x3{ public: float m[3][3]; }; // To allow inlining
  413. const ShadowMatrix3x3* Mat = (const ShadowMatrix3x3*)&mat;
  414. float xp = x * Mat->m[0][0] + y * Mat->m[1][0] + z * Mat->m[2][0];
  415. float yp = x * Mat->m[0][1] + y * Mat->m[1][1] + z * Mat->m[2][1];
  416. float zp = x * Mat->m[0][2] + y * Mat->m[1][2] + z * Mat->m[2][2];
  417. x = xp; y = yp; z = zp;
  418. return *this;
  419. }
  420. //! Operator for Point *= Matrix4x4.
  421. inline_ Point& operator*=(const Matrix4x4& mat)
  422. {
  423. class ShadowMatrix4x4{ public: float m[4][4]; }; // To allow inlining
  424. const ShadowMatrix4x4* Mat = (const ShadowMatrix4x4*)&mat;
  425. float xp = x * Mat->m[0][0] + y * Mat->m[1][0] + z * Mat->m[2][0] + Mat->m[3][0];
  426. float yp = x * Mat->m[0][1] + y * Mat->m[1][1] + z * Mat->m[2][1] + Mat->m[3][1];
  427. float zp = x * Mat->m[0][2] + y * Mat->m[1][2] + z * Mat->m[2][2] + Mat->m[3][2];
  428. x = xp; y = yp; z = zp;
  429. return *this;
  430. }
  431. // Cast operators
  432. //! Cast a Point to a HPoint. w is set to zero.
  433. operator HPoint() const;
  434. inline_ operator const float*() const { return &x; }
  435. inline_ operator float*() { return &x; }
  436. public:
  437. float x, y, z;
  438. };
  439. FUNCTION ICEMATHS_API void Normalize1(Point& a);
  440. FUNCTION ICEMATHS_API void Normalize2(Point& a);
  441. #endif //__ICEPOINT_H__