]> Shamusworld >> Repos - architektonas/blob - src/vector.h
Added ability to translate groups with Lines.
[architektonas] / src / vector.h
1 //\r
2 // vector.h (Last modified: 6/28/2001)\r
3 //\r
4 // Various structures used for 3 dimensional imaging\r
5 //\r
6 // by James L. Hammons\r
7 // (C) 2001 Underground Software\r
8 //\r
9 \r
10 #ifndef __VECTOR_H__\r
11 #define __VECTOR_H__\r
12 \r
13 // What we'll do here is create the vector type and use typedef to alias Point to it. Yeah, that's it.\r
14 \r
15 class Vector\r
16 {\r
17         public:\r
18                 Vector(double xx = 0, double yy = 0, double zz = 0);\r
19                 Vector(Vector head, Vector tail);               // Create vector from two points\r
20                 Vector operator=(Vector const v);\r
21                 Vector operator+(Vector const v);\r
22                 Vector operator-(Vector const v);\r
23                 Vector operator-(void);                                 // Unary negation\r
24                 Vector operator*(double const v);               // Vector times constant (double)\r
25                 Vector operator*(float const v);                // Vector times constant (float)\r
26                 Vector operator/(double const v);               // Vector divided by constant (double)\r
27                 Vector operator/(float const v);                // Vector divided by constant (float)\r
28                 Vector operator*(Vector const v);               // Vector product\r
29                 double Dot(Vector const v);                             // Dot product\r
30 \r
31                 Vector& operator*=(double const v);             // Vector times constant self-assignment\r
32                 Vector& operator/=(double const v);             // Vector divided by constant self-assignment\r
33                 Vector& operator+=(Vector const v);             // Vector plus Vector self-assignment\r
34                 Vector& operator+=(double const v);             // Vector plus constant self-assignment\r
35                 Vector& operator-=(Vector const v);             // Vector minus Vector self-assignment\r
36                 Vector& operator-=(double const v);             // Vector minus constant self-assignment\r
37 \r
38                 bool operator==(Vector const v);                // Check for equality\r
39                 bool operator!=(Vector const v);                // Check for inequality\r
40 \r
41                 Vector Unit(void);\r
42                 double Magnitude(void);\r
43                 double Angle(void);\r
44                 bool isZero(double epsilon = 1e-6);\r
45 \r
46                 // Class methods\r
47 \r
48                 static double Dot(Vector v1, Vector v2);\r
49                 static double Magnitude(Vector v1, Vector v2);\r
50                 static double Parameter(Vector v1, Vector v2, Vector p);\r
51                 static Vector Normal(Vector v1, Vector v2);\r
52 \r
53         public:\r
54                 double x, y, z;\r
55 };\r
56 \r
57 typedef Vector Point;\r
58 \r
59 #endif  // __VECTOR_H__\r