X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fvector.h;h=5ef0a9242b75188812cff6aee7fa8091990023e3;hb=6114b754fcd6e7d83c71dc2fa0ef2ec185387e12;hp=0551ea87cc8555a0309aa0ad1946d5f8d340c39b;hpb=f19a3a172c425b7fcc5a648a94870f0247c6be89;p=architektonas diff --git a/src/vector.h b/src/vector.h index 0551ea8..5ef0a92 100644 --- a/src/vector.h +++ b/src/vector.h @@ -1,54 +1,64 @@ -// -// 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(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 - - Vector Unit(void); - double Magnitude(void); - double Angle(void); - 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__ +// +// vector.h (Last modified: 6/28/2001) +// +// Various structures used for 3 dimensional imaging +// +// by James Hammons +// (C) 2001, 2018 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; +typedef Vector Point; + +class Vector +{ + public: + Vector(double xx = 0, double yy = 0, double zz = 0); + Vector(Vector tail, Vector head); // Create vector from two points + void SetAngleAndLength(double angle, double length); + 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); + bool isZero(double epsilon = 1e-6); + + // Class methods + + static double Dot(Vector v1, Vector v2); + static double Magnitude(Vector v1, Vector v2); + static double Angle(Point p1, Point p2); + static double Parameter(Vector v1, Vector v2, Vector p); + static Vector Normal(Vector v1, Vector v2); + static double AngleBetween(Vector a, Vector b); + + public: + double x, y, z; +}; + +#endif // __VECTOR_H__