00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00032 #ifndef __VECTOR_H__
00033 #define __VECTOR_H__
00034
00045 #include "fix.h"
00046
00047
00048
00069 class Vector3
00070 {
00071 public:
00075 inline Vector3()
00076 {}
00077
00085 inline Vector3(fix x,fix y,fix z)
00086 : X(x), Y(y), Z(z) {}
00087
00094 IMPORT Vector3 operator - () const;
00095
00106 IMPORT Vector3 operator + (const Vector3& vector) const;
00107
00118 IMPORT Vector3 operator - (const Vector3& vector) const;
00119
00131 IMPORT Vector3 operator * (fix scalar) const;
00132
00144 IMPORT Vector3 operator / (fix scalar) const;
00145
00158 IMPORT Vector3& operator += (const Vector3& vector);
00159
00172 IMPORT Vector3& operator -= (const Vector3& vector);
00173
00186 IMPORT Vector3& operator *= (fix scalar);
00187
00200 IMPORT Vector3& operator /= (fix scalar);
00201
00210 IMPORT bool operator == (const Vector3& vector) const;
00211
00220 inline bool operator != (const Vector3& vector) const
00221 { return !(*this==vector); }
00222
00234 IMPORT fix DotProduct(const Vector3& vector) const;
00235
00247 IMPORT Vector3 CrossProduct(const Vector3& vector) const;
00248
00255 IMPORT ufix Length() const;
00256
00274 IMPORT int CompareLength(ufix length) const;
00275
00293 IMPORT int CompareLengths(const Vector3& vector) const;
00294
00306 IMPORT uint32_t LengthSquared(uint32_t& fraction) const;
00307
00317 IMPORT Vector3 UnitVector() const;
00318
00331 IMPORT Vector3 Normal(const Vector3& vector) const;
00332
00342 IMPORT fixangle Angle(const Vector3& vector) const;
00343
00358 IMPORT Vector3 Normal(const Vector3& point1,const Vector3& point2) const;
00359
00371 IMPORT fixangle Angle(const Vector3& point1,const Vector3& point2) const;
00372
00381 IMPORT static void Translate(Vector3* outVectors,unsigned vectorCount,const Vector3* inVectors,const Vector3& offset);
00382
00391 IMPORT static void Scale(Vector3* outVectors,unsigned vectorCount,const Vector3* inVectors,fix scale);
00392
00393 private:
00394
00401 void NormaliseComponents(unsigned bits);
00402
00403 public:
00404 fix X;
00405 fix Y;
00406 fix Z;
00407 };
00408
00409
00413 typedef Vector3 Point3;
00414
00415
00416
00420 class Matrix3
00421 {
00422 public:
00426 inline Matrix3()
00427 {}
00428
00436 inline Matrix3(const Vector3 row1,const Vector3 row2,const Vector3 row3)
00437 : Row1(row1), Row2(row2), Row3(row3) {}
00438
00446 IMPORT Vector3 operator * (const Vector3& vector) const;
00447
00453 IMPORT Matrix3 Transposition() const;
00454
00463 IMPORT void Transform(Vector3* outVectors,unsigned vectorCount,const Vector3* inVectors);
00464 public:
00465 Vector3 Row1;
00466 Vector3 Row2;
00467 Vector3 Row3;
00468 };
00469
00470
00472
00473 #endif