3 2 dimensional vector (plainvector) implementation
20 ///Default constructor: both coordinates become 0
23 ///Constructing the instance from coordinates
24 xy(T a, T b) : x(a), y(a) { }
27 ///Gives back the square of the norm of the vector
32 ///Increments the left hand side by u
33 xy<T>& operator +=(const xy<T>& u){
39 ///Decrements the left hand side by u
40 xy<T>& operator -=(const xy<T>& u){
46 ///Multiplying the left hand side with a scalar
47 xy<T>& operator *=(const T &u){
53 ///Dividing the left hand side by a scalar
54 xy<T>& operator /=(const T &u){
60 ///Returns the scalar product of two vectors
61 T operator *(const xy<T>& u){
65 ///Returns the sum of two vectors
66 xy<T> operator+(const xy<T> &u) const {
71 ///Returns the difference of two vectors
72 xy<T> operator-(const xy<T> &u) const {
77 ///Returns a vector multiplied by a scalar
78 xy<T> operator*(const T &u) const {
83 ///Returns a vector divided by a scalar
84 xy<T> operator/(const T &u) const {
90 bool operator==(const xy<T> &u){
91 return (x==u.x) && (y==u.y);
95 bool operator!=(xy u){
96 return (x!=u.x) || (y!=u.y);
101 ///Reading a plainvector from a stream
104 std::istream& operator>>(std::istream &is, xy<T> &z)
111 ///Outputting a plainvector to a stream
114 std::ostream& operator<<(std::ostream &os, xy<T> z)
116 os << "(" << z.x << ", " << z.y << ")";