IcePoint.h 19 KB

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