17 #include "vtdata/config_vtdata.h"
29 #define acosf (float)acos
33 #define asinf (float)asin
37 #define atan2f (float)atan2
41 #define cosf (float)cos
45 #define sinf (float)sin
49 #define tanf (float)tan
53 #define logf (float)log
57 #define log10f (float)log10
61 #define powf (float)pow
65 #define sqrtf (float)sqrt
69 #define fabsf (float)fabs
74 #define PId 3.14159265358979323846264338
75 #define PIf 3.14159265358979323846264338f
76 #define PI2d 6.28318530717958647692528676
77 #define PI2f 6.28318530717958647692528676f
78 #define PID2d 1.57079632679489661923132169
79 #define PID2f 1.57079632679489661923132169f
80 #define PID3d 1.04719755119659774615421446
96 FPoint3(
float fx,
float fy,
float fz) { x=fx; y=fy; z=fz; }
99 float Length()
const {
return sqrtf(x*x+y*y+z*z); }
100 float LengthSquared()
const {
return x*x+y*y+z*z; }
101 FPoint3 &Normalize() {
float s = 1.0f/Length(); x*=s; y*=s; z*=s;
return (*
this); }
102 FPoint3 &SetLength(
float len) {
float s = len/Length(); x*=s; y*=s; z*=s;
return (*
this); }
103 void Set(
float fx,
float fy,
float fz) { x=fx; y=fy; z=fz; }
104 float Dot(
const FPoint3 &rhs)
const
106 return x*rhs.x+y*rhs.y+z*rhs.z;
108 float Dot(
const float *fp)
const
110 return x*fp[0]+y*fp[1]+z*fp[2];
114 return FPoint3(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x);
124 *
this = edge0.Cross(edge1);
129 FPoint3 &operator=(
const FPoint3 &v) { x = v.x; y = v.y; z = v.z;
return *
this; }
135 FPoint3 operator *(
float s)
const {
return FPoint3(x*s, y*s, z*s); }
136 FPoint3 operator *(
double s)
const {
return FPoint3((
float)(x*s), (
float)(y*s), (
float)(z*s)); }
137 FPoint3 operator /(
float s)
const {
return FPoint3(x/s, y/s, z/s); }
139 bool operator==(
const FPoint3 &v2)
const
140 {
return (x == v2.x && y == v2.y && z == v2.z); }
141 bool operator!=(
const FPoint3 &v2)
const
142 {
return (x != v2.x || y != v2.y || z != v2.z); }
144 void operator +=(
const FPoint3 &v) { x+=v.x; y+=v.y; z+=v.z; }
145 void operator -=(
const FPoint3 &v) { x-=v.x; y-=v.y; z-=v.z; }
146 void operator *=(
float s) { x*=s; y*=s; z*=s; }
147 void operator /=(
float s) { x/=s; y/=s; z/=s; }
151 float &operator[](
int nIndex) {
return *(&x+nIndex); }
152 const float &operator[](
int nIndex)
const {
return *(&x+nIndex); }
163 DPoint3() { x = y = z = 0.0f; }
164 DPoint3(
double fx,
double fy,
double fz) { x=fx; y=fy; z=fz; }
167 double Length()
const {
return sqrt(x*x+y*y+z*z); }
168 double LengthSquared()
const {
return x*x+y*y+z*z; }
171 double s = 1.0/Length();
175 DPoint3 &SetLength(
double len) {
double s = len/Length(); x*=s; y*=s; z*=s;
return (*
this); }
176 void Set(
double fx,
double fy,
double fz) { x=fx; y=fy; z=fz; }
177 double Dot(
const DPoint3 &rhs)
const
179 return x*rhs.x+y*rhs.y+z*rhs.z;
183 return DPoint3(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x);
186 DPoint3 &operator=(
const DPoint3 &v) { x = v.x; y = v.y; z = v.z;
return *
this; }
192 DPoint3 operator *(
double s)
const {
return DPoint3(x*s, y*s, z*s); }
193 DPoint3 operator /(
double s)
const {
return DPoint3(x/s, y/s, z/s); }
194 bool operator==(
const DPoint3 &v2)
const
195 {
return (x == v2.x && y == v2.y && z == v2.z); }
196 bool operator!=(
const DPoint3 &v2)
const
197 {
return (x != v2.x || y != v2.y || z != v2.z); }
200 double operator *(
const DPoint3 &v)
const {
return x*v.x + y*v.y + z*v.z; }
202 void operator +=(
const DPoint3 &v) { x+=v.x; y+=v.y; z+=v.z; }
203 void operator -=(
const DPoint3 &v) { x-=v.x; y-=v.y; z-=v.z; }
204 void operator *=(
double s) { x*=s; y*=s; z*=s; }
205 void operator /=(
double s) { x/=s; y/=s; z/=s; }
211 inline FPoint3::FPoint3(
const DPoint3 &v) { x = (float) v.x; y = (
float) v.y; z = (float) v.z; }
212 inline DPoint3::DPoint3(
const FPoint3 &v) { x = v.x; y = v.y; z = v.z; }
213 inline FPoint3 &FPoint3::operator=(
const DPoint3 &v) { x = (float) v.x; y = (
float) v.y; z = (float) v.z;
return *
this; }
214 inline DPoint3 &DPoint3::operator=(
const FPoint3 &v) { x = v.x; y = v.y; z = v.z;
return *
this; }
228 FPoint2(
int ix,
int iy) { x=(float)ix; y=(float)iy; }
229 FPoint2(
float fx,
float fy) { x=fx; y=fy; }
230 FPoint2(
double dx,
double dy) { x=(float)dx; y=(float)dy; }
233 float Length()
const {
return sqrtf(x*x+y*y); }
234 float LengthSquared()
const {
return x*x+y*y; }
235 FPoint2 &Normalize() {
float s = 1.0f/Length(); x*=s; y*=s;
return (*
this); }
236 FPoint2 &SetLength(
float len) {
float s = len/Length(); x*=s; y*=s;
return (*
this); }
237 void Set(
float fx,
float fy) { x=fx; y=fy; }
238 float Dot(
const FPoint2 &rhs)
const
240 return x*rhs.x+y*rhs.y;
242 void Mult(
const FPoint2 &factor) { x *= factor.x; y *= factor.y; }
243 void Mult(
const float fx,
const float fy) { x *= fx; y *= fy; }
244 void Div(
const FPoint2 &factor) { x /= factor.x; y /= factor.y; }
245 void Div(
const float fx,
const float fy) { x /= fx; y /= fy; }
246 void Rotate(
double radians)
249 x = x * (float) cos(radians) - y * (float) sin(radians);
250 y = tempx * (float) sin(radians) + y * (float) cos(radians);
256 return (x*rhs.y - y*rhs.x);
260 FPoint2 &operator=(
const FPoint2 &v) { x = v.x; y = v.y;
return *
this; }
268 void operator +=(
const FPoint2 &v) { x+=v.x; y+=v.y; }
269 void operator -=(
const FPoint2 &v) { x-=v.x; y-=v.y; }
270 void operator *=(
float s) { x*=s; y*=s; }
271 void operator /=(
float s) { x/=s; y/=s; }
273 bool operator==(
const FPoint2 &v)
const {
return (x == v.x && y == v.y); }
274 bool operator!=(
const FPoint2 &v)
const {
return (x != v.x || y != v.y); }
286 DPoint2(
int ix,
int iy) { x=(double)ix; y=(double)iy; }
287 DPoint2(
float fx,
float fy) { x=fx; y=fy; }
288 DPoint2(
double fx,
double fy) { x=fx; y=fy; }
291 double Length()
const {
return sqrt(x*x+y*y); }
292 double LengthSquared()
const {
return (x*x+y*y); }
293 DPoint2 &Normalize() {
double s = 1.0f/Length(); x*=s; y*=s;
return (*
this); }
294 DPoint2 &SetLength(
double len) {
double s = len/Length(); x*=s; y*=s;
return (*
this); }
295 void Set(
double fx,
double fy) { x=fx; y=fy; }
296 double Dot(
const DPoint2 &rhs)
const
298 return x*rhs.x + y*rhs.y;
300 void Mult(
const DPoint2 &factor) { x *= factor.x; y *= factor.y; }
301 void Mult(
const double fx,
const double fy) { x *= fx; y *= fy; }
302 void Div(
const DPoint2 &factor) { x /= factor.x; y /= factor.y; }
303 void Div(
const double fx,
const double fy) { x /= fx; y /= fy; }
304 void Rotate(
double radians)
307 x = x * cos(radians) - y * sin(radians);
308 y = tempx * sin(radians) + y * cos(radians);
314 return (x*rhs.y - y*rhs.x);
318 DPoint2 &operator=(
const DPoint2 &v) { x = v.x; y = v.y;
return *
this; }
326 void operator +=(
const DPoint2 &v) { x+=v.x; y+=v.y; }
327 void operator -=(
const DPoint2 &v) { x-=v.x; y-=v.y; }
328 void operator *=(
double s) { x*=s; y*=s; }
329 void operator /=(
double s) { x/=s; y/=s; }
331 bool operator==(
const DPoint2 &v)
const {
return (x == v.x && y == v.y); }
332 bool operator!=(
const DPoint2 &v)
const {
return (x != v.x || y != v.y); }
341 inline FPoint2::FPoint2(
const DPoint2 &d) { x=(float)d.x; y=(
float)d.y; }
342 inline DPoint2::DPoint2(
const FPoint2 &f) { x=f.x; y=f.y; }
352 IPoint2(
int ix,
int iy) { x=ix; y=iy; }
354 float Length()
const {
return sqrtf((
float)x*x + (
float)y*y); }
355 void Set(
int ix,
int iy) { x=ix; y=iy; }
356 IPoint2 &operator=(
const IPoint2 &v) { x = v.x; y = v.y;
return *
this; }
361 IPoint2 operator *(
float f)
const {
return IPoint2((
int)(x*f), (
int)(y*f)); }
363 void operator +=(
const IPoint2 &v) { x+=v.x; y+=v.y; }
364 void operator -=(
const IPoint2 &v) { x-=v.x; y-=v.y; }
365 void operator *=(
int s) { x*=s; y*=s; }
366 void operator *=(
float f) { x=(int)(x*f); y=(int)(y*f); }
368 bool operator==(
const IPoint2 &v)
const {
return (x == v.x && y == v.y); }
369 bool operator!=(
const IPoint2 &v)
const {
return (x != v.x || y != v.y); }
413 void Mult(
double factor);
416 void InsertPointAfter(
int iInsertAfter,
const DPoint2 &Point);
417 void RemovePoint(
int i);
427 bool IsConvex()
const;
429 void SetSafePoint(
int index,
const DPoint2 &p);
430 double Length()
const;
435 int n = (int) GetSize();
437 for (
int p=n-1,q=0; q<n; p=q++)
460 float SegmentLength(uint i)
const;
463 bool NearestSegment(
const FPoint2 &Point,
int &iIndex,
float &dist,
FPoint2 &Intersection)
const;
464 void InsertPointAfter(
int iInsertAfter,
const FPoint2 &Point);
466 bool IsConvex()
const;
471 int size = v.GetSize();
473 for (
int i = 0; i < size; i++)
481 int size = v.GetSize();
486 for (
int i = 0; i < size; i++)
497 int size = v.GetSize();
499 for (
int i = 0; i < size; i++)
507 int size = v.GetSize();
512 for (
int i = 0; i < size; i++)
540 double &dist,
DPoint3 &Intersection)
const;
566 int size = v.GetSize();
568 for (
int i = 0; i < size; i++)
576 int size = v.GetSize();
578 for (
int i = 0; i < size; i++)
593 typedef enum { COLINEAR, COPLANAR, PARALLEL, FACING_AWAY, INTERSECTING } IntersectionType;
601 FPlane(
float a,
float b,
float c,
float d) { x = a; y = b; z = c; w = d; }
622 void Set(
float a,
float b,
float c,
float d) { x = a; y = b; z = c; w = d; }
623 float Distance(
const FPoint3 &v)
const
651 FBox3(
float x1,
float y1,
float z1,
float x2,
float y2,
float z2)
660 min.Set(1E10f, 1E10f, 1E10f);
661 max.Set(-1E10f, -1E10f, -1E10f);
663 void Set(
float x1,
float y1,
float z1,
float x2,
float y2,
float z2)
668 FPoint3 Center()
const {
return ((min + max) * 0.5); }
669 void GrowToContainPoint(
const FPoint3 &p)
671 if (p.x < min.x) min.x = p.x;
672 if (p.y < min.y) min.y = p.y;
673 if (p.z < min.z) min.z = p.z;
674 if (p.x > max.x) max.x = p.x;
675 if (p.y > max.y) max.y = p.y;
676 if (p.z > max.z) max.z = p.z;
678 void GrowToContainLine(
const FLine3 &line)
680 for (uint i = 0; i < line.GetSize(); i++)
681 GrowToContainPoint(line[i]);
683 void GrowToContainBox(
const FBox3 &box)
685 GrowToContainPoint(box.min);
686 GrowToContainPoint(box.max);
703 center = src.Center();
704 radius = (center - src.min).Length();
716 void Set(
const FPoint3 &p,
float fRadius)
721 void Empty() { center.Set(0,0,0); radius = 0; }
723 void GrowToContain(
const FSphere &sh)
725 FPoint3 dv = sh.center - center;
726 float dv_len = dv.Length();
728 if (dv_len == 0 && sh.radius > radius)
730 else if (dv_len+sh.radius > radius)
732 FPoint3 e1 = center - (dv*(radius/dv_len));
733 FPoint3 e2 = sh.center + (dv*(sh.radius/dv_len));
734 center = (e1 + e2) * 0.5f;
735 radius = (e2 - center).Length();
738 bool operator==(
const FSphere &v)
const {
return (center == v.center && radius == v.radius); }
739 bool operator!=(
const FSphere &v)
const {
return (center != v.center || radius != v.radius); }
749 typedef std::vector<DLine2> DLine2Array;
750 typedef std::vector<FLine3> FLine3Array;
765 uint NumTotalVertices()
const;
766 bool ComputeExtents(
DRECT &rect)
const;
767 bool ContainsPoint(
const DPoint2 &p)
const;
769 int WhichRing(
int &iVtxNum)
const;
775 void Mult(
double factor);
794 static int s_previous_poly;
810 void Mult(
float factor);
812 uint NumTotalVertices()
const;
813 int WhichRing(
int &iVtxNum)
const;
830 DRECT() { left = top = right = bottom = 0.0; }
831 DRECT(
double l,
double t,
double r,
double b) { left = l; top = t; right = r; bottom = b; }
833 void SetRect(
double l,
double t,
double r,
double b) { left = l; top = t; right = r; bottom = b; }
835 double Width()
const {
return right - left; }
837 double Height()
const {
return top - bottom; };
839 bool IsNull()
const {
return (left == 0.0 && top == 0.0 && right == 0.0 && bottom == 0.0); }
841 bool IsEmpty()
const {
return (left == right && top == bottom); }
842 void Empty() { left = top = right = bottom = 0.0; }
845 if (left > right) {
double tmp = left; left = right; right = tmp; }
846 if (bottom > top) {
double tmp = bottom; bottom = top; top = tmp; }
848 void GetCenter(
DPoint2 &p)
const
850 p.x = (left + right) / 2.0;
851 p.y = (bottom + top) / 2.0;
855 return DPoint2((left + right) / 2.0, (bottom + top) / 2);
861 bool ContainsPoint(
const DPoint2 &p,
bool bInclusive =
false)
const
864 return (p.x >= left && p.x <= right && p.y >= bottom && p.y <= top);
866 return (p.x > left && p.x < right && p.y > bottom && p.y < top);
868 bool ContainsPoint(
const DPoint3 &p)
const
870 return (p.x > left && p.x < right && p.y > bottom && p.y < top);
874 bool ContainsRect(
const DRECT &r2)
const
876 return (r2.left >= left && r2.right <= right &&
877 r2.bottom >= bottom && r2.top <= top);
879 bool OverlapsRect(
const DRECT &r2)
const
881 if ( left > r2.right ||
889 void Grow(
double x,
double y)
896 void GrowToContainPoint(
const DPoint2 &p)
898 if (p.x < left) left = p.x;
899 if (p.x > right) right = p.x;
900 if (p.y < bottom) bottom = p.y;
901 if (p.y > top) top = p.y;
903 void GrowToContainLine(
const DLine2 &line)
906 int size = line.GetSize();
907 for (
int i = 0; i < size; i++)
910 if (p.x < left) left = p.x;
911 if (p.x > right) right = p.x;
912 if (p.y < bottom) bottom = p.y;
913 if (p.y > top) top = p.y;
916 void GrowToContainLine(
const DLine3 &line)
919 int size = line.GetSize();
920 for (
int i = 0; i < size; i++)
923 if (p.x < left) left = p.x;
924 if (p.x > right) right = p.x;
925 if (p.y < bottom) bottom = p.y;
926 if (p.y > top) top = p.y;
930 void GrowToContainRect(
const DRECT &r2)
932 if (r2.left < left) left = r2.left;
933 if (r2.right > right) right = r2.right;
934 if (r2.top > top) top = r2.top;
935 if (r2.bottom < bottom) bottom = r2.bottom;
937 bool operator==(
const DRECT &v)
const
939 return (left == v.left && top == v.top && right == v.right && bottom == v.bottom);
941 bool operator!=(
const DRECT &v)
const
943 return (left != v.left || top != v.top || right != v.right || bottom != v.bottom);
965 FRECT() { left = top = right = bottom = 0.0; }
966 FRECT(
float l,
float t,
float r,
float b)
968 left = l; top = t; right = r; bottom = b;
970 void SetRect(
float l,
float t,
float r,
float b)
972 left = l; top = t; right = r; bottom = b;
975 float Width()
const {
return right - left; }
977 float Height()
const {
return top - bottom; };
979 bool IsEmpty()
const {
return (left == right && top == bottom); }
980 void Empty() { left = top = right = bottom = 0.0; }
983 if (left > right) {
float tmp = left; left = right; right = tmp; }
984 if (bottom > top) {
float tmp = bottom; bottom = top; top = tmp; }
986 bool ContainsPoint(
float x,
float y)
const
988 return (x > left && x < right && y > bottom && y < top);
990 void Center(
FPoint2 ¢er)
const
992 center.x = (left + right)/2;
993 center.y = (bottom + top)/2;
997 return FPoint2((left + right)/2, (bottom + top)/2);
999 void operator+=(
const FPoint2 &delta)
1001 left += delta.x; top += delta.y;
1002 right += delta.x; bottom += delta.y;
1024 void Set(
int i,
int j,
double v) { data[i][j] = v; }
1025 double Get(
int i,
int j)
const {
return data[i][j]; }
1026 double operator()(
int i,
int j)
const {
return data[i][j]; }
1029 void AxisAngle(
const DPoint3 &vec,
double theta);
1031 void SetByMatrix4(
const DMatrix4 &m);
1043 void Set(
int i,
int j,
double v) { data[i][j] = v; }
1044 double Get(
int i,
int j)
const {
return data[i][j]; }
1045 double operator()(
int i,
int j)
const {
return data[i][j]; }
1048 void AxisAngle(
const DPoint3 &vec,
double theta);
1068 void Set(
int col,
int row,
float v) { data[col][row] = v; }
1069 float Get(
int col,
int row)
const {
return data[col][row]; }
1070 void SetRow(
int row,
float f0,
float f1,
float f2);
1073 bool IsIdentity()
const;
1074 void AxisAngle(
const FPoint3 &vec,
double theta);
1078 void SetFromMatrix4(
const FMatrix4 &mat);
1082 void PostMult(
const FMatrix3 &mat);
1085 float operator()(
int col,
int row)
const {
return data[col][row]; }
1092 typedef float FMatrix4Data[4][4];
1103 void Set(
int col,
int row,
float v) { data[col][row] = v; }
1104 float Get(
int col,
int row)
const {
return data[col][row]; }
1105 void SetRow(
int row,
float f0,
float f1,
float f2,
float f3);
1107 void SetData(FMatrix4Data data_in) { memcpy(data, data_in, 64); }
1108 const FMatrix4Data &GetData()
const {
return data; }
1112 bool IsIdentity()
const;
1113 void AxisAngle(
const FPoint3 &vec,
double theta);
1114 void Translate(
const FPoint3 &vec);
1120 void SetFromMatrix3(
const FMatrix3 &mat);
1121 void MakeScale(
float x,
float y,
float z);
1124 void PostMult(
const FMatrix4 &mat);
1132 double d = 1.0 / (data[3][0]*v.x + data[3][1]*v.y + data[3][2]*v.z + data[3][3]);
1133 return FPoint3( (
float)((data[0][0]*v.x + data[0][1]*v.y + data[0][2]*v.z + data[0][3])*d),
1134 (
float)((data[1][0]*v.x + data[1][1]*v.y + data[1][2]*v.z + data[1][3])*d),
1135 (
float)((data[2][0]*v.x + data[2][1]*v.y + data[2][2]*v.z + data[2][3])*d));
1139 double d = 1.0 / (data[0][3]*v.x + data[1][3]*v.y + data[2][3]*v.z + data[3][3]);
1140 return FPoint3( (
float)((data[0][0]*v.x + data[1][0]*v.y + data[2][0]*v.z + data[3][0])*d),
1141 (
float)((data[0][1]*v.x + data[1][1]*v.y + data[2][1]*v.z + data[3][1])*d),
1142 (
float)((data[0][2]*v.x + data[1][2]*v.y + data[2][2]*v.z + data[3][2])*d));
1146 float operator()(
int col,
int row)
const {
return data[col][row]; }
1148 bool operator==(
const FMatrix4 &mat)
const;
1149 bool operator!=(
const FMatrix4 &mat)
const;
1157 SetFromMatrix4(mat);
1162 SetFromMatrix3(mat);
1166 inline bool FMatrix4::operator==(
const FMatrix4 &mat)
const
1168 return memcmp(data, mat.data,
sizeof(data)) == 0;
1171 inline bool FMatrix4::operator!=(
const FMatrix4 &mat)
const
1173 return memcmp(data, mat.data,
sizeof(data)) != 0;
1188 FQuat(
float qx,
float qy,
float qz,
float qw) { x = qx; y = qy; z = qz; w = qw; }
1189 FQuat(
const FQuat &q) { x = q.x; y = q.y; z = q.z; w = q.w; }
1190 FQuat(
const FPoint3 &axis,
float angle) { AxisAngle(axis, angle); }
1192 void Init() { x = 0; y = 0; z = 0; w = 1; }
1193 void Set(
float qx,
float qy,
float qz,
float qw) { x = qx; y = qy; z = qz; w = qw; }
1196 void SetFromVector(
const FPoint3 &direction);
1197 void AxisAngle(
const FPoint3 &axis,
float angle);
1201 float LengthSquared()
const {
return x*x + y*y + z*z + w*w; }
1202 const FQuat Inverse()
const
1204 float l2 = LengthSquared();
1205 return FQuat( -x / l2, -y / l2, -z / l2, w / l2);
1214 FQuat &operator=(
const FQuat &q) { x = q.x; y = q.y; z = q.z; w = q.w;
return *
this; }
1232 void FromMatrix(
const FMatrix4 &matrix);
1234 void Interpolate(
const FPQ &from,
const FPQ &to,
float f);
1260 RGBi(
short _r,
short _g,
short _b) { r = _r; g = _g; b = _b; }
1261 RGBi(
const class RGBf &v) { *
this = v; }
1263 void Set(
short _r,
short _g,
short _b) { r = _r; g = _g; b = _b; }
1264 RGBi operator +(
const RGBi &v)
const {
return RGBi(r+v.r, g+v.g, b+v.b); }
1265 RGBi operator +(
const class RGBAi &v)
const;
1266 RGBi operator -(
const RGBi &v)
const {
return RGBi(r-v.r, g-v.g, b-v.b); }
1267 RGBi operator *(
float s)
const {
return RGBi((
short)(r*s), (
short)(g*s), (
short)(b*s)); }
1268 RGBi operator /(
float s)
const {
return RGBi((
short)(r/s), (
short)(g/s), (
short)(b/s)); }
1269 void operator *=(
float s) { r=(short)(r*s); g=(short)(g*s); b=(short)(b*s); }
1270 void operator /=(
float s) { r=(short)(r/s); g=(short)(g/s); b=(short)(b/s); }
1272 void operator +=(
const RGBi &v) { r=r+v.r; g=g+v.g; b=b+v.b; }
1273 void operator +=(
const class RGBAi &v);
1278 RGBi &operator=(
const RGBi &v) { r = v.r; g = v.g; b = v.b;
return *
this; }
1279 RGBi &operator=(
const class RGBf &v);
1281 bool operator==(
const RGBi &v)
const {
return (r == v.r && g == v.g && b == v.b); }
1282 bool operator!=(
const RGBi &v)
const {
return (r != v.r || g != v.g || b != v.b); }
1296 RGBAi(
short _r,
short _g,
short _b,
short _a = 255) { r = _r; g = _g; b = _b; a = _a; }
1297 RGBAi(
const class RGBi &v) { *
this = v; }
1299 void Set(
short _r,
short _g,
short _b,
short _a = 255) { r = _r; g = _g; b = _b; a = _a; }
1300 RGBAi operator +(
const RGBAi &v)
const {
return RGBAi(r+v.r, g+v.g, b+v.b, a+v.a); }
1301 RGBAi operator -(
const RGBAi &v)
const {
return RGBAi(r-v.r, g-v.g, b-v.b, a+v.a); }
1302 RGBAi operator *(
float s)
const {
return RGBAi((
short)(r*s), (
short)(g*s), (
short)(b*s), (
short)(a*s)); }
1303 RGBAi operator /(
float s)
const {
return RGBAi((
short)(r/s), (
short)(g/s), (
short)(b/s), (
short)(a/s)); }
1304 void operator *=(
float s) { r=(short)(r*s); g=(short)(g*s); b=(short)(b*s); a=(short)(a*s); }
1305 void operator /=(
float s) { r=(short)(r/s); g=(short)(g/s); b=(short)(b/s); a=(short)(a/s); }
1308 void MultRGB(
float s) { r=(short)(r*s); g=(short)(g*s); b=(short)(b*s); }
1313 RGBAi &operator=(
const RGBi &v) { r = v.r; g = v.g; b = v.b; a = 255;
return *
this; }
1318 inline void RGBi::operator +=(
const class RGBAi &v) { r=r+v.r; g=g+v.g; b=b+v.b; }
1319 inline RGBi RGBi::operator +(
const class RGBAi &v)
const {
return RGBi(r+v.r, g+v.g, b+v.b); }
1330 RGBf(
float _r,
float _g,
float _b) { r = _r; g = _g; b = _b; }
1331 RGBf(
const class RGBi &v) { *
this = v; }
1332 RGBf(
const class RGBAf &v) { *
this = v; }
1334 void Set(
float _r,
float _g,
float _b) { r = _r; g = _g; b = _b; }
1335 RGBf operator +(
const RGBf &v)
const {
return RGBf(r+v.r, g+v.g, b+v.b); }
1336 RGBf operator -(
const RGBf &v)
const {
return RGBf(r-v.r, g-v.g, b-v.b); }
1337 RGBf operator *(
float s)
const {
return RGBf(r*s, g*s, b*s); }
1338 RGBf operator /(
float s)
const {
return RGBf(r/s, g/s, b/s); }
1339 void operator +=(
const RGBf &v) { r+=v.r; g+=v.g; b+=v.b; }
1340 void operator *=(
float s) { r*=s; g*=s; b*=s; }
1341 void operator /=(
float s) { r/=s; g/=s; b/=s; }
1344 RGBf &operator=(
const RGBf &v) { r = v.r; g = v.g; b = v.b;
return *
this; }
1345 RGBf &operator=(
const class RGBi &v);
1348 bool operator==(
const RGBf &v2)
const
1349 {
return (r == v2.r && g == v2.g && b == v2.b); }
1350 bool operator!=(
const RGBf &v2)
const
1351 {
return (r != v2.r || g != v2.g || b != v2.b); }
1356 inline RGBi &RGBi::operator=(
const class RGBf &v)
1358 r = (short) (v.r * 255.999f);
1359 g = (short) (v.g * 255.999f);
1360 b = (short) (v.b * 255.999f);
1364 inline RGBf &RGBf::operator=(
const class RGBi &v)
1382 RGBAf(
float _r,
float _g,
float _b) { r = _r; g = _g; b = _b; a = 1.0f; }
1383 RGBAf(
float _r,
float _g,
float _b,
float _a) { r = _r; g = _g; b = _b; a = _a; }
1384 RGBAf(
const class RGBf &v) { *
this = v; }
1386 void Set(
float _r,
float _g,
float _b,
float _a) { r = _r; g = _g; b = _b; a = _a; }
1387 RGBAf operator +(
const RGBAf &v)
const {
return RGBAf(r+v.r, g+v.g, b+v.b, a+v.a); }
1388 RGBAf operator -(
const RGBAf &v)
const {
return RGBAf(r-v.r, g-v.g, b-v.b, a+v.a); }
1389 RGBAf operator *(
float s)
const {
return RGBAf(r*s, g*s, b*s); }
1390 RGBAf operator /(
float s)
const {
return RGBAf(r/s, g/s, b/s); }
1391 void operator *=(
float s) { r*=s; g*=s; b*=s; }
1394 RGBAf &operator=(
const RGBf &v) { r = v.r; g = v.g; b = v.b; a = 1.0f;
return *
this; }
1397 bool operator==(
const RGBAf &v2)
const
1398 {
return (r == v2.r && g == v2.g && b == v2.b && a == v2.a); }
1399 bool operator!=(
const RGBAf &v2)
const
1400 {
return (r != v2.r || g != v2.g || b != v2.b || a != v2.a); }
1405 inline RGBf &RGBf::operator=(
const class RGBAf &v)
1431 LocaleWrap(
int category,
const char *locale_string);
1435 std::string m_old_locale;
1442 float random_offset(
float x);
1443 float random(
float x);
1445 float vt_log2f(
float n);
1446 bool CrossingsTest(
const DPoint2 *pgon,
int numverts,
const DPoint2 &point);
1447 bool CrossingsTest(
const DPoint3 *pgon,
int numverts,
const DPoint2 &point);
1456 bool PlaneIntersection(
const FPlane &plane1,
const FPlane &plane2,
1462 float DistanceSegmentToSegment(
const FPoint3 &A1,
const FPoint3 &A2,
1467 void vtLogMatrix(
const FMatrix4 &mat);
1468 void vtLogMatrix(
const FMatrix3 &mat);
1469 bool RaySphereIntersection(
const FPoint3 &rkOrigin,
const FPoint3 &rkDirection,
1471 void ProjectionXZ(
const FLine3 &fline3,
DLine2 &dline2);
1473 void ProjectionXZ(
const DLine2 &dline2,
float fY,
FLine3 &fline3);
1476 #endif // VTMATHTYPESH