2021-12-26 21:19:38 +01:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2011-08-30 18:38:33 +02:00
|
|
|
*
|
2021-12-26 21:19:38 +01:00
|
|
|
* ScummVM is the legal property of its developers, whose names
|
2011-08-30 18:38:33 +02:00
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
2021-12-26 18:47:58 +01:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2014-04-05 18:18:42 +02:00
|
|
|
*
|
2012-12-19 23:15:43 +01:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2011-08-30 18:38:33 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-12-19 23:15:43 +01:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-04-05 18:18:42 +02:00
|
|
|
*
|
2012-12-19 23:15:43 +01:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 18:47:58 +01:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-08-30 18:38:33 +02:00
|
|
|
*
|
|
|
|
*/
|
2011-08-01 22:16:15 +02:00
|
|
|
|
2011-09-10 17:46:07 +02:00
|
|
|
#ifndef MATH_RECT2D_H
|
|
|
|
#define MATH_RECT2D_H
|
2011-08-01 22:16:15 +02:00
|
|
|
|
2011-09-10 17:46:07 +02:00
|
|
|
#include "math/vector2d.h"
|
|
|
|
#include "math/line2d.h"
|
2011-08-01 22:16:15 +02:00
|
|
|
|
2011-09-10 17:46:07 +02:00
|
|
|
namespace Math {
|
2011-08-01 22:16:15 +02:00
|
|
|
|
2011-08-30 18:38:33 +02:00
|
|
|
class Segment2d;
|
2011-08-01 22:16:15 +02:00
|
|
|
|
|
|
|
class Rect2d {
|
|
|
|
public:
|
|
|
|
Rect2d();
|
2011-08-30 18:38:33 +02:00
|
|
|
Rect2d(const Vector2d &topLeft, const Vector2d &bottomRight);
|
2011-08-01 22:16:15 +02:00
|
|
|
Rect2d(const Vector2d &topLeft, const Vector2d &topRight,
|
2021-04-05 23:08:48 +02:00
|
|
|
const Vector2d &bottomLeft, const Vector2d &bottomRight);
|
2011-08-01 22:16:15 +02:00
|
|
|
|
2011-09-18 16:23:55 +02:00
|
|
|
void rotateAround(const Vector2d &point, const Angle &angle);
|
|
|
|
void rotateAroundCenter(const Angle &angle);
|
2011-10-18 17:42:12 +02:00
|
|
|
void moveCenterTo(const Vector2d &pos);
|
|
|
|
void scale(float amount);
|
|
|
|
void translate(const Vector2d &vec);
|
2011-08-01 22:16:15 +02:00
|
|
|
bool intersectsRect(const Rect2d &rect) const;
|
|
|
|
bool intersectsCircle(const Vector2d ¢er, float radius) const;
|
2011-08-30 18:38:33 +02:00
|
|
|
bool containsPoint(const Vector2d &point) const;
|
2011-08-01 22:16:15 +02:00
|
|
|
|
|
|
|
Vector2d getCenter() const;
|
2011-08-30 18:38:33 +02:00
|
|
|
Vector2d getTopLeft() const;
|
|
|
|
Vector2d getTopRight() const;
|
|
|
|
Vector2d getBottomLeft() const;
|
|
|
|
Vector2d getBottomRight() const;
|
2011-08-01 22:16:15 +02:00
|
|
|
float getWidth() const;
|
|
|
|
float getHeight() const;
|
2011-08-30 18:38:33 +02:00
|
|
|
Vector2d getIntersection(const Vector2d &start, const Vector2d &direction, Segment2d *edge) const;
|
2011-08-01 22:16:15 +02:00
|
|
|
|
|
|
|
// private:
|
|
|
|
Vector2d _topLeft;
|
|
|
|
Vector2d _topRight;
|
|
|
|
Vector2d _bottomLeft;
|
|
|
|
Vector2d _bottomRight;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|