Code: Select all
+-----+
| |
| |
| |
+-----+
Code: Select all
#-----+
| |
| |
| |
+-----+
#
That's because counting starts with one but indicing starts with zero, for example: An array with just one element would have the lenght 1 but you have to accces array(0) because indicing start at zero.
But that don't have to be an error, you don't have to change this behavior.
But then the error is in this function:
Code: Select all
110 bool isPointInside(const position2d<T>& pos) const
111 {
112 return (UpperLeftCorner.X <= pos.X &&
113 UpperLeftCorner.Y <= pos.Y &&
114 LowerRightCorner.X >= pos.X &&
115 LowerRightCorner.Y >= pos.Y);
116 }
Code: Select all
110 bool isPointInside(const position2d<T>& pos) const
111 {
112 return (UpperLeftCorner.X <= pos.X &&
113 UpperLeftCorner.Y <= pos.Y &&
114 (LowerRightCorner.X - 1) >= pos.X &&
115 (LowerRightCorner.Y - 1) >= pos.Y);
116 }
Code: Select all
185 //! Returns width of rectangle.
186 T getWidth() const
187 {
188 return LowerRightCorner.X - 1 - UpperLeftCorner.X;
189 }
190
191 //! Returns height of rectangle.
192 T getHeight() const
193 {
194 return LowerRightCorner.Y - 1 - UpperLeftCorner.Y;
195 }
Code: Select all
#-----+
| |
| |
| |
+-----#
EDIT: Sorry if my writing is a bit unclear, but I hope you understand the basic Problem.