Sorry, the name chosen was a mistake.
9 ///\brief A simple two dimensional vector and a bounding box implementation
11 /// The class \ref hugo::xy "xy" implements
12 ///a two dimensional vector with the usual
15 /// The class \ref hugo::BoundingBox "BoundingBox" can be used to determine
16 /// the rectangular bounding box a set of \ref hugo::xy "xy"'s.
18 ///\author Attila Bernath
26 /// A two dimensional vector (plainvector) implementation
28 /// A two dimensional vector (plainvector) implementation
29 ///with the usual vector
32 ///\author Attila Bernath
40 ///Default constructor: both coordinates become 0
43 ///Constructing the instance from coordinates
44 xy(T a, T b) : x(a), y(b) { }
47 ///Gives back the square of the norm of the vector
52 ///Increments the left hand side by u
53 xy<T>& operator +=(const xy<T>& u){
59 ///Decrements the left hand side by u
60 xy<T>& operator -=(const xy<T>& u){
66 ///Multiplying the left hand side with a scalar
67 xy<T>& operator *=(const T &u){
73 ///Dividing the left hand side by a scalar
74 xy<T>& operator /=(const T &u){
80 ///Returns the scalar product of two vectors
81 T operator *(const xy<T>& u){
85 ///Returns the sum of two vectors
86 xy<T> operator+(const xy<T> &u) const {
91 ///Returns the difference of two vectors
92 xy<T> operator-(const xy<T> &u) const {
97 ///Returns a vector multiplied by a scalar
98 xy<T> operator*(const T &u) const {
103 ///Returns a vector divided by a scalar
104 xy<T> operator/(const T &u) const {
110 bool operator==(const xy<T> &u){
111 return (x==u.x) && (y==u.y);
114 ///Testing inequality
115 bool operator!=(xy u){
116 return (x!=u.x) || (y!=u.y);
121 ///Read a plainvector from a stream
127 std::istream& operator>>(std::istream &is, xy<T> &z)
134 ///Write a plainvector to a stream
140 std::ostream& operator<<(std::ostream &os, xy<T> z)
142 os << "(" << z.x << ", " << z.y << ")";
147 /// A class to calculate or store the bounding box of plainvectors.
149 /// A class to calculate or store the bounding box of plainvectors.
151 ///\author Attila Bernath
154 xy<T> bottom_left, top_right;
158 ///Default constructor: an empty bounding box
159 BoundingBox() { _empty = true; }
161 ///Constructing the instance from one point
162 BoundingBox(xy<T> a) { bottom_left=top_right=a; _empty = false; }
164 ///Is there any point added
169 ///Gives back the bottom left corner (if the bounding box is empty, then the return value is not defined)
170 xy<T> bottomLeft() const {
174 ///Gives back the top right corner (if the bounding box is empty, then the return value is not defined)
175 xy<T> topRight() const {
179 ///Checks whether a point is inside a bounding box
180 bool inside(const xy<T>& u){
184 return ((u.x-bottom_left.x)*(top_right.x-u.x) >= 0 &&
185 (u.y-bottom_left.y)*(top_right.y-u.y) >= 0 );
189 ///Increments a bounding box with a point
190 BoundingBox& operator +=(const xy<T>& u){
192 bottom_left=top_right=u;
196 if (bottom_left.x > u.x) bottom_left.x = u.x;
197 if (bottom_left.y > u.y) bottom_left.y = u.y;
198 if (top_right.x < u.x) top_right.x = u.x;
199 if (top_right.y < u.y) top_right.y = u.y;
204 ///Sums a bounding box and a point
205 BoundingBox operator +(const xy<T>& u){
206 BoundingBox b = *this;
210 ///Increments a bounding box with an other bounding box
211 BoundingBox& operator +=(const BoundingBox &u){
213 *this += u.bottomLeft();
214 *this += u.topRight();
219 ///Sums two bounding boxes
220 BoundingBox operator +(const BoundingBox& u){
221 BoundingBox b = *this;
225 };//class Boundingbox