4 #include <iostream> // Needed for 'friend ostream' below
9 * Represents a 3d vector (x/y/z)
11 * @author Andrew Mustun
17 Vector(double vx, double vy, double vz = 0.0);
19 //Not sure why this is here, explicit means no implicit conversion when assigning values
21 //OK, you might want this in certain situations such as
22 // Vector(true), but still not 100% sure why this is here.
23 explicit Vector(bool valid);
26 void set(double vx, double vy, double vz = 0.0);
27 void setPolar(double radius, double angle);
29 double distanceTo(const Vector & v) const;
31 double angleTo(const Vector & v) const;
32 double magnitude() const;
33 Vector lerp(const Vector & v, double t) const;
35 bool isInWindow(const Vector & firstCorner, const Vector & secondCorner);
37 Vector move(Vector offset);
38 Vector rotate(double ang);
39 Vector rotate(Vector center, double ang);
40 Vector scale(Vector factor);
41 Vector scale(Vector center, Vector factor);
42 Vector mirror(Vector axisPoint1, Vector axisPoint2);
44 Vector operator+(const Vector & v) const;
45 Vector operator-(const Vector & v) const;
46 Vector operator*(double s) const;
47 Vector operator/(double s) const;
48 Vector operator-() const;
50 void operator+=(const Vector & v);
51 void operator-=(const Vector & v);
52 void operator*=(double s);
54 bool operator==(const Vector & v) const;
55 bool operator!=(const Vector & v) const;
58 static Vector minimum(const Vector & v1, const Vector & v2);
59 static Vector maximum(const Vector & v1, const Vector & v2);
60 static Vector crossP(const Vector & v1, const Vector & v2);
61 static double dotP(const Vector & v1, const Vector & v2);
63 friend std::ostream & operator<<(std::ostream &, const Vector & v);
76 #endif // __VECTOR_H__