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