equal
deleted
inserted
replaced
59 |
59 |
60 ///Constructing the instance from coordinates |
60 ///Constructing the instance from coordinates |
61 xy(T a, T b) : x(a), y(b) { } |
61 xy(T a, T b) : x(a), y(b) { } |
62 |
62 |
63 |
63 |
|
64 ///Conversion constructor |
|
65 template<class TT> xy(const xy<TT> &p) : x(p.x), y(p.y) {} |
|
66 |
64 ///Gives back the square of the norm of the vector |
67 ///Gives back the square of the norm of the vector |
65 T normSquare(){ |
68 T normSquare(){ |
66 return x*x+y*y; |
69 return x*x+y*y; |
67 }; |
70 }; |
68 |
71 |
101 |
104 |
102 ///Returns the sum of two vectors |
105 ///Returns the sum of two vectors |
103 xy<T> operator+(const xy<T> &u) const { |
106 xy<T> operator+(const xy<T> &u) const { |
104 xy<T> b=*this; |
107 xy<T> b=*this; |
105 return b+=u; |
108 return b+=u; |
|
109 }; |
|
110 |
|
111 ///Returns the neg of the vectors |
|
112 xy<T> operator-() const { |
|
113 xy<T> b=*this; |
|
114 b.x=-b.x; b.y=-b.y; |
|
115 return b; |
106 }; |
116 }; |
107 |
117 |
108 ///Returns the difference of two vectors |
118 ///Returns the difference of two vectors |
109 xy<T> operator-(const xy<T> &u) const { |
119 xy<T> operator-(const xy<T> &u) const { |
110 xy<T> b=*this; |
120 xy<T> b=*this; |