00001
00002
00003
00004
00005
00006
00007
00088 #ifndef VTDATATYPESH
00089 #define VTDATATYPESH
00090
00091 #include <math.h>
00092 #include "Array.h"
00093 #include "Array.inl"
00094
00095 #ifndef PI
00096 #define PI 3.141592653589793238
00097 #endif
00098 #ifndef PI2
00099 #define PIf 3.141592653589793238f
00100 #define PI2 6.283185307179586476
00101 #define PI2f 6.283185307179586476f
00102 #define PID2 1.570796326794896619
00103 #define PID2f 1.570796326794896619f
00104 #endif
00105
00106 #ifndef NULL
00107 #define NULL 0
00108 #endif
00109
00110 class FPoint3 {
00111 public:
00112 FPoint3() { x = y = z = 0.0f; }
00113 FPoint3(float fx, float fy, float fz) { x=fx; y=fy; z=fz; }
00114
00115 float Length() const { return sqrtf(x*x+y*y+z*z); }
00116 float LengthSquared() const { return x*x+y*y+z*z; }
00117 void Normalize() { float s = 1.0f/Length(); x*=s; y*=s; z*=s; }
00118 void Set(float fx, float fy, float fz) { x=fx; y=fy; z=fz; }
00119 float Dot(const FPoint3 &rhs) const
00120 {
00121 return x*rhs.x+y*rhs.y+z*rhs.z;
00122 }
00123 float Dot(const float *fp) const
00124 {
00125 return x*fp[0]+y*fp[1]+z*fp[2];
00126 }
00127 FPoint3 Cross(const FPoint3 &v)
00128 {
00129 return FPoint3(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x);
00130 }
00131 FPoint3 &operator=(const FPoint3 &v) { x = v.x; y = v.y; z = v.z; return *this; }
00132 FPoint3 operator +(const FPoint3 &v) const { return FPoint3(x+v.x, y+v.y, z+v.z); }
00133 FPoint3 operator -(const FPoint3 &v) const { return FPoint3(x-v.x, y-v.y, z-v.z); }
00134 FPoint3 operator *(float s) const { return FPoint3(x*s, y*s, z*s); }
00135 FPoint3 operator /(float s) const { return FPoint3(x/s, y/s, z/s); }
00136 FPoint3 operator -() { return FPoint3(-x, -y, -z); }
00137 bool operator==(const FPoint3 &v2)
00138 { return (x == v2.x && y == v2.y && z == v2.z); }
00139 bool operator!=(const FPoint3 &v2)
00140 { return (x != v2.x || y != v2.y || z != v2.z); }
00141
00142 void operator +=(const FPoint3 &v) { x+=v.x; y+=v.y; z+=v.z; }
00143 void operator -=(const FPoint3 &v) { x-=v.x; y-=v.y; z-=v.z; }
00144 void operator *=(float s) { x*=s; y*=s; z*=s; }
00145 void operator /=(float s) { x/=s; y/=s; z/=s; }
00146
00147 float x, y, z;
00148 };
00149
00150 class DPoint3 {
00151 public:
00152 DPoint3() { x = y = z = 0.0f; }
00153 DPoint3(double fx, double fy, double fz) { x=fx; y=fy; z=fz; }
00154
00155 double Length() const { return sqrt(x*x+y*y+z*z); }
00156 void Normalize() { double s = 1.0f/Length(); x*=s; y*=s; z*=s; }
00157 void Set(double fx, double fy, double fz) { x=fx; y=fy; z=fz; }
00158 DPoint3 Cross(const DPoint3 &v)
00159 {
00160 return DPoint3(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x);
00161 }
00162 DPoint3 &operator=(const DPoint3 &v) { x = v.x; y = v.y; z = v.z; return *this; }
00163 DPoint3 operator +(const DPoint3 &v) const { return DPoint3(x+v.x, y+v.y, z+v.z); }
00164 DPoint3 operator -(const DPoint3 &v) const { return DPoint3(x-v.x, y-v.y, z-v.z); }
00165 DPoint3 operator *(double s) const { return DPoint3(x*s, y*s, z*s); }
00166 DPoint3 operator /(double s) const { return DPoint3(x/s, y/s, z/s); }
00167
00168
00169 double operator *(const DPoint3 &v) const { return x*v.x + y*v.y + z*v.z; }
00170
00171 void operator +=(const DPoint3 &v) { x+=v.x; y+=v.y; z+=v.z; }
00172 void operator -=(const DPoint3 &v) { x-=v.x; y-=v.y; z-=v.z; }
00173 void operator *=(double s) { x*=s; y*=s; z*=s; }
00174 void operator /=(double s) { x/=s; y/=s; z/=s; }
00175
00176 double x, y, z;
00177 };
00178
00180
00181 class FPlane : public FPoint3
00182 {
00183 public:
00184 FPlane() {}
00185 FPlane(float a, float b, float c, float d) { x = a; y = b; z = c; w = d; }
00186 const FPlane &operator=(const FPlane &rhs)
00187 {
00188 x = rhs.x;
00189 y = rhs.y;
00190 z = rhs.z;
00191 w = rhs.w;
00192 return *this;
00193 }
00194 void Set(const FPoint3& p, const FPoint3& n)
00195 {
00196 x = n.x;
00197 y = n.y;
00198 z = n.z;
00199 w = -n.Dot(p);
00200 }
00201 void Set(float a, float b, float c, float d) { x = a; y = b; z = c; w = d; }
00202 float Distance(const FPoint3 &v) const
00203 {
00204 return Dot(v) + w;
00205 }
00206
00207 float w;
00208 };
00209
00211
00212 class FPoint2;
00213 class DPoint2;
00214
00215 class FPoint2 {
00216 public:
00217 FPoint2() { x = y = 0.0f; }
00218 FPoint2(int ix, int iy) { x=(float)ix; y=(float)iy; }
00219 FPoint2(float fx, float fy) { x=fx; y=fy; }
00220 FPoint2(double dx, double dy) { x=(float)dx; y=(float)dy; }
00221 FPoint2(const DPoint2 &d);
00222
00223 float Length() const { return sqrtf(x*x+y*y); }
00224 void Normalize() { float s = 1.0f/Length(); x*=s; y*=s; }
00225 void Set(float fx, float fy) { x=fx; y=fy; }
00226
00227
00228 FPoint2 &operator=(const FPoint2 &v) { x = v.x; y = v.y; return *this; }
00229 FPoint2 &operator=(const class DPoint2 &v);
00230
00231 FPoint2 operator +(const FPoint2 &v) const { return FPoint2(x+v.x, y+v.y); }
00232 FPoint2 operator -(const FPoint2 &v) const { return FPoint2(x-v.x, y-v.y); }
00233 FPoint2 operator *(float s) const { return FPoint2(x*s, y*s); }
00234
00235 void operator +=(const FPoint2 &v) { x+=v.x; y+=v.y; }
00236 void operator -=(const FPoint2 &v) { x-=v.x; y-=v.y; }
00237 void operator *=(float s) { x*=s; y*=s; }
00238
00239 bool operator==(const FPoint2 &v) { return (x == v.x && y == v.y); }
00240 bool operator!=(const FPoint2 &v) { return (x != v.x || y != v.y); }
00241
00242 float x, y;
00243 };
00244
00245 class DPoint2 {
00246 public:
00247 DPoint2() { x = y = 0.0f; }
00248 DPoint2(int ix, int iy) { x=(double)ix; y=(double)iy; }
00249 DPoint2(float fx, float fy) { x=fx; y=fy; }
00250 DPoint2(double fx, double fy) { x=fx; y=fy; }
00251 DPoint2(const FPoint2 &f);
00252
00253 double Length() const { return sqrt(x*x+y*y); }
00254 void Normalize() { double s = 1.0/Length(); x*=s; y*=s; }
00255 void Set(double fx, double fy) { x=fx; y=fy; }
00256 void Rotate(double radians)
00257 {
00258 double tempx = x;
00259 x = x * cos(radians) - y * sin(radians);
00260 y = tempx * sin(radians) + y * cos(radians);
00261 }
00262
00263
00264 DPoint2 &operator=(const DPoint2 &v) { x = v.x; y = v.y; return *this; }
00265 DPoint2 &operator=(const class FPoint2 &v);
00266
00267 DPoint2 operator +(const DPoint2 &v) const { return DPoint2(x+v.x, y+v.y); }
00268 DPoint2 operator -(const DPoint2 &v) const { return DPoint2(x-v.x, y-v.y); }
00269 DPoint2 operator *(double s) const { return DPoint2(x*s, y*s); }
00270 DPoint2 operator /(double s) const { return DPoint2(x/s, y/s); }
00271
00272 void operator +=(const DPoint2 &v) { x+=v.x; y+=v.y; }
00273 void operator -=(const DPoint2 &v) { x-=v.x; y-=v.y; }
00274 void operator *=(double s) { x*=s; y*=s; }
00275 void operator /=(double s) { x/=s; y/=s; }
00276
00277 bool operator==(const DPoint2 &v) { return (x == v.x && y == v.y); }
00278
00279 double x, y;
00280 };
00281
00282
00283
00284 inline FPoint2::FPoint2(const DPoint2 &d) { x=(float)d.x; y=(float)d.y; }
00285 inline DPoint2::DPoint2(const FPoint2 &f) { x=f.x; y=f.y; }
00286
00287
00288 class IPoint2 {
00289 public:
00290 IPoint2() {}
00291 IPoint2(int ix, int iy) { x=ix; y=iy; }
00292
00293 float Length() const { return sqrtf((float)x*x + (float)y*y); }
00294 void Set(int ix, int iy) { x=ix; y=iy; }
00295 IPoint2 &operator=(const IPoint2 &v) { x = v.x; y = v.y; return *this; }
00296
00297 IPoint2 operator +(const IPoint2 &v) const { return IPoint2(x+v.x, y+v.y); }
00298 IPoint2 operator -(const IPoint2 &v) const { return IPoint2(x-v.x, y-v.y); }
00299 IPoint2 operator *(int s) const { return IPoint2(x*s, y*s); }
00300 IPoint2 operator *(float f) const { return IPoint2((int)(x*f), (int)(y*f)); }
00301
00302 void operator +=(const IPoint2 &v) { x+=v.x; y+=v.y; }
00303 void operator -=(const IPoint2 &v) { x-=v.x; y-=v.y; }
00304 void operator *=(int s) { x*=s; y*=s; }
00305 void operator *=(float f) { x=(int)(x*f); y=(int)(y*f); }
00306
00307 int x, y;
00308 };
00309
00310 inline FPoint2 &FPoint2::operator=(const class DPoint2 &v)
00311 {
00312 x = (float) v.x;
00313 y = (float) v.y;
00314 return *this;
00315 }
00316
00317 inline DPoint2 &DPoint2::operator=(const class FPoint2 &v)
00318 {
00319 x = v.x;
00320 y = v.y;
00321 return *this;
00322 }
00323
00324
00325
00326
00327
00328 class DLine2 : public Array<DPoint2>
00329 {
00330 public:
00331 DLine2() {}
00332
00333 DLine2(DLine2 &ref) { *this = ref; }
00334
00335
00336 DLine2 &operator=(const class DLine2 &v);
00337 DLine2 &operator=(const class FLine2 &v);
00338
00339 void RemovePoint(int i);
00340 bool ContainsPoint(const DPoint2 &p);
00341 };
00342
00343 class FLine2 : public Array<FPoint2>
00344 {
00345 public:
00346 FLine2() {}
00347
00348 FLine2(FLine2 &ref) { *this = ref; }
00349
00350
00351 FLine2 &operator=(const class FLine2 &v);
00352 FLine2 &operator=(const class DLine2 &v);
00353 };
00354
00355 inline DLine2 &DLine2::operator=(const class DLine2 &v)
00356 {
00357 int size = v.GetSize();
00358 SetSize(size);
00359 for (int i = 0; i < size; i++)
00360 SetAt(i, v.GetAt(i));
00361
00362 return *this;
00363 }
00364
00365 inline DLine2 &DLine2::operator=(const class FLine2 &v)
00366 {
00367 int size = v.GetSize();
00368 SetSize(size);
00369
00370 FPoint2 p1;
00371 DPoint2 p2;
00372 for (int i = 0; i < size; i++)
00373 {
00374 p1 = v.GetAt(i);
00375 p2 = p1;
00376 SetAt(i, p2);
00377 }
00378 return *this;
00379 }
00380
00381 inline FLine2 &FLine2::operator=(const class FLine2 &v)
00382 {
00383 int size = v.GetSize();
00384 SetSize(size);
00385 for (int i = 0; i < size; i++)
00386 SetAt(i, v.GetAt(i));
00387
00388 return *this;
00389 }
00390
00391 inline FLine2 &FLine2::operator=(const class DLine2 &v)
00392 {
00393 int size = v.GetSize();
00394 SetSize(size);
00395
00396 DPoint2 p1;
00397 FPoint2 p2;
00398 for (int i = 0; i < size; i++)
00399 {
00400 p1 = v.GetAt(i);
00401 p2 = p1;
00402 SetAt(i, p2);
00403 }
00404 return *this;
00405 }
00406
00408
00409 class DLine3 : public Array<DPoint3>
00410 {
00411 public:
00412 DLine3() {}
00413
00414 DLine3(DLine3 &ref) { *this = ref; }
00415
00416
00417 DLine3 &operator=(const class DLine3 &v);
00418
00419
00420 void RemovePoint(int i);
00421 };
00422
00423 class FLine3 : public Array<FPoint3>
00424 {
00425 public:
00426 FLine3() {}
00427
00428 FLine3(FLine3 &ref) { *this = ref; }
00429
00430
00431 FLine3 &operator=(const class FLine3 &v);
00432
00433 };
00434
00435 inline DLine3 &DLine3::operator=(const class DLine3 &v)
00436 {
00437 int size = v.GetSize();
00438 SetSize(size);
00439 for (int i = 0; i < size; i++)
00440 SetAt(i, v.GetAt(i));
00441
00442 return *this;
00443 }
00444
00445 inline FLine3 &FLine3::operator=(const class FLine3 &v)
00446 {
00447 int size = v.GetSize();
00448 SetSize(size);
00449 for (int i = 0; i < size; i++)
00450 SetAt(i, v.GetAt(i));
00451
00452 return *this;
00453 }
00454
00456
00457 class FBox3
00458 {
00459 public:
00460 FBox3() {}
00461 FBox3(FPoint3 &min1, FPoint3 &max1) { min = min1; max = max1; }
00462
00463 void Set(float x1, float y1, float z1, float x2, float y2, float z2)
00464 {
00465 min.Set(x1, y1, z1);
00466 max.Set(x2, y2, z2);
00467 }
00468 FPoint3 Center() const { return ((min + max) * 0.5); }
00469
00470 FPoint3 min, max;
00471 };
00472
00474
00475 class FSphere
00476 {
00477 public:
00478 FSphere() {}
00479 FSphere(const FBox3 &src)
00480 {
00481 center = src.Center();
00482 radius = (center - src.min).Length();
00483 }
00484 FSphere(const FPoint3& p, float fRadius)
00485 {
00486 Set(p, fRadius);
00487 }
00488 const FSphere &operator=(const FSphere &rhs)
00489 {
00490 center = rhs.center;
00491 radius = rhs.radius;
00492 return *this;
00493 }
00494 void Set(const FPoint3& p, float fRadius)
00495 {
00496 center = p;
00497 radius = fRadius;
00498 }
00499 void Empty() { center.Set(0,0,0); radius = 0; }
00500
00501 FPoint3 center;
00502 float radius;
00503 };
00504
00506
00507
00508
00509
00510 class DPolyArray2 : public Array<DLine2 *>
00511 {
00512 public:
00513 DPolyArray2() { m_previous_poly = -1; }
00514
00515 int FindPoly(DPoint2 p);
00516
00517
00518 int m_previous_poly;
00519 };
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529 class DRECT
00530 {
00531 public:
00532 DRECT() { left = top = right = bottom = 0.0; }
00533 DRECT(double l, double t, double r, double b) { left = l; top = t; right = r; bottom = b; }
00534
00535 void SetRect(double l, double t, double r, double b) { left = l; top = t; right = r; bottom = b; }
00536
00537 double Width() const { return right - left; }
00538
00539 double Height() const { return top - bottom; };
00540
00541 bool IsNull() const { return (left == 0.0 && top == 0.0 && right == 0.0 && bottom == 0.0); }
00542
00543 bool IsEmpty() const { return (left == right && top == bottom); }
00544 void Sort()
00545 {
00546 double tmp;
00547 if (left > right)
00548 {
00549 tmp = left;
00550 left = right;
00551 right = tmp;
00552 }
00553 if (bottom > top)
00554 {
00555 tmp = bottom;
00556 bottom = top;
00557 top = tmp;
00558 }
00559 }
00560 bool ContainsPoint(const DPoint2 &p) const
00561 {
00562 return (p.x > left && p.x < right && p.y > bottom && p.y < top);
00563 }
00564 void GrowToContainPoint(const DPoint2 &p)
00565 {
00566 if (p.x < left) left = p.x;
00567 if (p.x > right) right = p.x;
00568 if (p.y < bottom) bottom = p.y;
00569 if (p.y > top) top = p.y;
00570 }
00571 void GrowToContainLine(const DLine2 &line)
00572 {
00573 DPoint2 p;
00574 int size = line.GetSize();
00575 for (int i = 0; i < size; i++)
00576 {
00577 p = line.GetAt(i);
00578 if (p.x < left) left = p.x;
00579 if (p.x > right) right = p.x;
00580 if (p.y < bottom) bottom = p.y;
00581 if (p.y > top) top = p.y;
00582 }
00583 }
00584
00585 void GrowToContainRect(const DRECT &r2)
00586 {
00587 if (r2.left < left) left = r2.left;
00588 if (r2.right > right) right = r2.right;
00589 if (r2.top > top) top = r2.top;
00590 if (r2.bottom < bottom) bottom = r2.bottom;
00591 }
00592 bool operator==(const DRECT &v)
00593 {
00594 return (left == v.left && top == v.top && right == v.right && bottom == v.bottom);
00595 }
00596 bool operator!=(const DRECT &v)
00597 {
00598 return (left != v.left || top != v.top || right != v.right || bottom != v.bottom);
00599 }
00600
00601 double left;
00602 double top;
00603 double right;
00604 double bottom;
00605 };
00606
00607 class FRECT
00608 {
00609 public:
00610 void SetRect(float l, float t, float r, float b)
00611 {
00612 left = l; top = t; right = r; bottom = b;
00613 }
00614
00615 float Width() const { return right - left; }
00616
00617 float Height() const { return top - bottom; };
00618 bool ContainsPoint(float x, float y)
00619 {
00620 return (x > left && x < right && y > bottom && y < top);
00621 }
00622
00623 float left;
00624 float top;
00625 float right;
00626 float bottom;
00627 };
00628
00630
00631
00632 class DMatrix3;
00633 class DMatrix4;
00634
00635 class DMatrix3
00636 {
00637 public:
00638 void Set(int i1, int i2, double v) { data[i1][i2] = v; }
00639 double Get(int i1, int i2) const { return data[i1][i2]; }
00640
00641 void Transform(const DPoint3 &src, DPoint3 &dst) const;
00642 void SetByMatrix4(const DMatrix4 &m);
00643
00644 protected:
00645 double data[3][3];
00646 };
00647 class DMatrix4
00648 {
00649 public:
00650 void Set(int i1, int i2, double v) { data[i1][i2] = v; }
00651 double Get(int i1, int i2) const { return data[i1][i2]; }
00652
00653 void Identity();
00654 void AxisAngle(const DPoint3 &vec, double theta);
00655 void Invert(const DMatrix4 &src);
00656
00657 protected:
00658 double data[4][4];
00659 };
00660
00662
00663 class FMatrix3
00664 {
00665 public:
00666 void Set(int i1, int i2, float v) { data[i1][i2] = v; }
00667 float Get(int i1, int i2) const { return data[i1][i2]; }
00668
00669 void Transform(const FPoint3 &src, FPoint3 &dst) const;
00670 void SetByMatrix4(const class FMatrix4 &m);
00671
00672 protected:
00673 float data[3][3];
00674 };
00675
00676 class FMatrix4
00677 {
00678 public:
00679 void Set(int i1, int i2, float v) { data[i1][i2] = v; }
00680 float Get(int i1, int i2) const { return data[i1][i2]; }
00681
00682
00683 void Identity();
00684 bool IsIdentity() const;
00685 void AxisAngle(const FPoint3 &vec, double theta);
00686 void Translate(const FPoint3 &vec);
00687 void Invert(const FMatrix4 &src);
00688 FPoint3 GetTrans() const;
00689 void SetTrans(FPoint3 pos);
00690
00691
00692 void Transform(const FPoint3 &src, FPoint3 &dst) const;
00693 void TransformVector(const FPoint3 &tmp, FPoint3 &dst) const;
00694
00695 protected:
00696 float data[4][4];
00697 };
00698
00700
00701
00702
00703
00704
00705 class RGBi
00706 {
00707 public:
00708 RGBi() {}
00709 RGBi(short _r, short _g, short _b) { r = _r; g = _g; b = _b; }
00710 RGBi(const class RGBf &v) { *this = v; }
00711
00712 void Set(short _r, short _g, short _b) { r = _r; g = _g; b = _b; }
00713 RGBi operator +(const RGBi &v) const { return RGBi(r+v.r, g+v.g, b+v.b); }
00714 RGBi operator -(const RGBi &v) const { return RGBi(r-v.r, g-v.g, b-v.b); }
00715 RGBi operator *(float s) const { return RGBi((short)(r*s), (short)(g*s), (short)(b*s)); }
00716 RGBi operator /(float s) const { return RGBi((short)(r/s), (short)(g/s), (short)(b/s)); }
00717 void operator *=(float s) { r=(short)(r*s); g=(short)(g*s); b=(short)(b*s); }
00718
00719
00720 RGBi &operator=(const RGBi &v) { r = v.r; g = v.g; b = v.b; return *this; }
00721 RGBi &operator=(const class RGBf &v);
00722
00723 bool operator==(const RGBi &v) { return (r == v.r && g == v.g && b == v.b); }
00724 bool operator!=(const RGBi &v) { return (r != v.r || g != v.g || b != v.b); }
00725
00726 short r, g, b;
00727 };
00728
00729
00730
00731
00732 class RGBf
00733 {
00734 public:
00735 RGBf() {}
00736 RGBf(float _r, float _g, float _b) { r = _r; g = _g; b = _b; }
00737 RGBf(const class RGBi &v) { *this = v; }
00738
00739 void Set(float _r, float _g, float _b) { r = _r; g = _g; b = _b; }
00740 RGBf operator +(const RGBf &v) const { return RGBf(r+v.r, g+v.g, b+v.b); }
00741 RGBf operator -(const RGBf &v) const { return RGBf(r-v.r, g-v.g, b-v.b); }
00742 RGBf operator *(float s) const { return RGBf(r*s, g*s, b*s); }
00743 RGBf operator /(float s) const { return RGBf(r/s, g/s, b/s); }
00744 void operator *=(float s) { r*=s; g*=s; b*=s; }
00745
00746
00747 RGBf &operator=(const RGBf &v) { r = v.r; g = v.g; b = v.b; return *this; }
00748 RGBf &operator=(const class RGBi &v);
00749 RGBf &operator=(const class RGBAf &v);
00750
00751 bool operator==(const RGBf &v2)
00752 { return (r == v2.r && g == v2.g && b == v2.b); }
00753 bool operator!=(const RGBf &v2)
00754 { return (r != v2.r || g != v2.g || b != v2.b); }
00755
00756 float r, g, b;
00757 };
00758
00759 inline RGBi &RGBi::operator=(const class RGBf &v)
00760 {
00761 r = (int) (v.r * 255.999f);
00762 g = (int) (v.g * 255.999f);
00763 b = (int) (v.b * 255.999f);
00764 return *this;
00765 }
00766
00767 inline RGBf &RGBf::operator=(const class RGBi &v)
00768 {
00769 r = v.r / 255.0f;
00770 g = v.g / 255.0f;
00771 b = v.b / 255.0f;
00772 return *this;
00773 }
00774
00776
00777
00778 class RGBAf
00779 {
00780 public:
00781 RGBAf() {}
00782 RGBAf(float _r, float _g, float _b) { r = _r; g = _g; b = _b; a = 1.0f; }
00783 RGBAf(float _r, float _g, float _b, float _a) { r = _r; g = _g; b = _b; a = _a; }
00784 RGBAf(const class RGBf &v) { *this = v; }
00785
00786 void Set(float _r, float _g, float _b) { r = _r; g = _g; b = _b; }
00787 RGBAf operator +(const RGBAf &v) const { return RGBAf(r+v.r, g+v.g, b+v.b, a+v.a); }
00788 RGBAf operator -(const RGBAf &v) const { return RGBAf(r-v.r, g-v.g, b-v.b, a+v.a); }
00789 RGBAf operator *(float s) const { return RGBAf(r*s, g*s, b*s); }
00790 RGBAf operator /(float s) const { return RGBAf(r/s, g/s, b/s); }
00791 void operator *=(float s) { r*=s; g*=s; b*=s; }
00792
00793
00794 RGBAf &operator=(const RGBf &v) { r = v.r; g = v.g; b = v.b; a = 1.0f; return *this; }
00795
00796 float r, g, b, a;
00797 };
00798
00799 inline RGBf &RGBf::operator=(const class RGBAf &v)
00800 {
00801 r = v.r;
00802 g = v.g;
00803 b = v.b;
00804 return *this;
00805 }
00806
00807
00808
00809
00810
00811 float random_offset(float x);
00812 float random(float x);
00813 bool CrossingsTest(DPoint2 *pgon, int numverts, const DPoint2 &point);
00814
00815 #endif