]> Shamusworld >> Repos - ttedit/blobdiff - src/vector.h
Added preview window to file loading dialog. :-)
[ttedit] / src / vector.h
old mode 100755 (executable)
new mode 100644 (file)
index a7e36ee..4504fe4
-//\r
-// VECTOR.H - vector class definition\r
-//\r
-// by James L. Hammons\r
-// (C) 2003 Underground Software\r
-//\r
-\r
-#ifndef __VECTOR_H__\r
-#define __VECTOR_H__\r
-\r
-struct vector\r
-{\r
-       double x, y, z;\r
-\r
-       vector(double a1=0.0, double b1=0.0, double c1=0.0, double a2=0.0, double b2=0.0, double c2=0.0);\r
-       vector(const vector &v1, const vector &v2);\r
-       vector& operator=(const vector &v);\r
-       bool operator==(const vector &v);\r
-       void unitize(void);\r
-       vector operator*(const vector &v);                      // Cross product: "this" x "v"\r
-       vector operator+(const vector &v);\r
-       vector operator-(const vector &v);\r
-       double dot(const vector &v1, const vector &v2);\r
-       double dot(const vector &v);\r
-       double distance(const vector &v);                       // Pythagoras extended to 3 dimensions\r
-       double length(void);\r
-       void operator*=(const double &d);\r
-       void operator/=(const double &d);\r
-       void operator+=(const vector &v);\r
-       void operator-=(const vector &v);\r
-       vector operator*(const double &d);                      // Scale vector by amount\r
-       void zero(const double epsilon);\r
-};\r
-\r
-#endif // __VECTOR_H__\r
+#if 0
+
+//
+// VECTOR.H - vector class definition
+//
+// by James L. Hammons
+// (C) 2003 Underground Software
+//
+
+#ifndef __VECTOR_H__
+#define __VECTOR_H__
+
+struct vector
+{
+       double x, y, z;
+
+       vector(double a1=0.0, double b1=0.0, double c1=0.0, double a2=0.0, double b2=0.0, double c2=0.0);
+       vector(const vector &v1, const vector &v2);
+       vector& operator=(const vector &v);
+       bool operator==(const vector &v);
+       void unitize(void);
+       vector operator*(const vector &v);                      // Cross product: "this" x "v"
+       vector operator+(const vector &v);
+       vector operator-(const vector &v);
+       double dot(const vector &v1, const vector &v2);
+       double dot(const vector &v);
+       double distance(const vector &v);                       // Pythagoras extended to 3 dimensions
+       double length(void);
+       void operator*=(const double &d);
+       void operator/=(const double &d);
+       void operator+=(const vector &v);
+       void operator-=(const vector &v);
+       vector operator*(const double &d);                      // Scale vector by amount
+       void zero(const double epsilon = 1.0e-6);
+};
+
+#endif // __VECTOR_H__
+
+#else
+
+//
+// vector.h (Last modified: 6/28/2001)
+//
+// Various structures used for 3 dimensional imaging
+//
+// by James L. Hammons
+// (C) 2001 Underground Software
+//
+
+#ifndef __VECTOR_H__
+#define __VECTOR_H__
+
+// What we'll do here is create the vector type and use typedef to alias Point to it. Yeah, that's it.
+
+class Vector
+{
+       public:
+//             Vector(double xx = 0, double yy = 0, double zz = 0);
+               Vector(double x1 = 0, double y1 = 0, double z1 = 0, double x2 = 0, double y2 = 0, double z2 = 0);
+               Vector(Vector head, Vector tail);               // Create vector from two points
+               Vector operator=(Vector const v);
+               Vector operator+(Vector const v);
+               Vector operator-(Vector const v);
+               Vector operator-(void);                                 // Unary negation
+               Vector operator*(double const v);               // Vector times constant (double)
+               Vector operator*(float const v);                // Vector times constant (float)
+               Vector operator/(double const v);               // Vector divided by constant (double)
+               Vector operator/(float const v);                // Vector divided by constant (float)
+               Vector operator*(Vector const v);               // Vector product
+               double Dot(Vector const v);                             // Dot product
+
+               Vector& operator*=(double const v);             // Vector times constant self-assignment
+               Vector& operator/=(double const v);             // Vector divided by constant self-assignment
+               Vector& operator+=(Vector const v);             // Vector plus Vector self-assignment
+               Vector& operator+=(double const v);             // Vector plus constant self-assignment
+               Vector& operator-=(Vector const v);             // Vector minus Vector self-assignment
+               Vector& operator-=(double const v);             // Vector minus constant self-assignment
+
+               bool operator==(Vector const v);                // Check for equality
+               bool operator!=(Vector const v);                // Check for inequality
+
+               Vector Unit(void);
+               double Magnitude(void);
+               double Angle(void);                                             // Angle of this vector WRT positive X-axis
+               double Angle(Vector v);                                 // Angle between these two vectors
+               bool isZero(double epsilon = 1e-6);
+
+               // Class methods
+
+               static double Dot(Vector v1, Vector v2);
+               static double Magnitude(Vector v1, Vector v2);
+
+       public:
+               double x, y, z;
+};
+
+typedef Vector Point;
+
+#endif // __VECTOR_H__
+
+#endif
+