A rotated 2-dimensional ellipse in the plane. More...
#include <Ellipse2D.hpp>
Public Types | |
typedef Point2D::value_type | value_type |
The type of the stored x, y coordinates, and the rotation. | |
Public Member Functions | |
Ellipse2D () | |
Constructor for an all-zero Ellipse2D. | |
Ellipse2D (const Point2D ¢er, const Point2D &radius, value_type rotation=0.0) | |
Constructor with specified center point, radius, and rotation. | |
Ellipse2D (value_type x_center, value_type y_center, value_type x_radius, value_type y_radius, value_type rotation=0.0) | |
Constructor with all values given. | |
virtual const UINT32 | getUsedMemory () const |
std::string | toString () const |
Accessor methods for information about this ellipse | |
const Point2D & | getCenter () const |
Returns the center point of this Ellipse. | |
const Point2D & | getRadius () const |
Returns the radius of this Ellipse. | |
value_type | getRotation () const |
Setter methods for changing this ellipse | |
void | setCenter (const Point2D &p) |
Sets the center point of this Ellipse2D. | |
void | setCenter (value_type x, value_type y) |
Sets the center point of this Ellipse2D. | |
void | setRadius (const Point2D &p) |
Sets the radius of this Ellipse. Must be non-negative. | |
void | setRadius (value_type x_length, value_type y_width) |
Sets the radius of this Ellipse2D. Must be non-negative. | |
void | setRotation (value_type r) |
Geometrical relations to other objects | |
bool | containsPoint (const Point2D &point) const |
Returns true if the given Point2D is inside this ellipse or on its outline. | |
Protected Attributes | |
Point2D | m_center |
Point2D | m_radius |
value_type | m_rotation |
Private Member Functions | |
void | verifyNumericRanges () |
Friends | |
bool | operator!= (const Ellipse2D &, const Ellipse2D &) |
bool | operator== (const Ellipse2D &, const Ellipse2D &) |
A rotated 2-dimensional ellipse in the plane.
This ellipse is defined by its center point, the rotation of the ellipse's main (x) axis measured from the global x-axis, and the radius of the ellipse's x- and y-axis.
The rotation denotes the rotation of this ellipse' x-axis compared to the original x-axis. The two radii denote the radius length of this ellipse in the ellipse' coordinate system, i.e. the distance from the center point to each outline.
The size argument must be non-negative. The rotation argument must be in the range [-pi,pi], which can be obtained by using normalizeRadians().
Definition at line 30 of file Ellipse2D.hpp.
The type of the stored x, y coordinates, and the rotation.
Definition at line 34 of file Ellipse2D.hpp.
Constructor for an all-zero Ellipse2D.
Definition at line 18 of file Ellipse2D.cpp.
datatypes::Ellipse2D::Ellipse2D | ( | const Point2D & | center, |
const Point2D & | radius, | ||
value_type | rotation = 0.0 |
||
) |
Constructor with specified center point, radius, and rotation.
center | The center point |
radius | The size of the ellipse in the ellipse' coordinate system. Must be non-negative. |
rotation | The rotation of the ellipse' coordinate system around its center point in [radians]. Must be in the interval [-pi,pi], which can be obtained by using normalizeRadians(). |
Definition at line 26 of file Ellipse2D.cpp.
datatypes::Ellipse2D::Ellipse2D | ( | value_type | x_center, |
value_type | y_center, | ||
value_type | x_radius, | ||
value_type | y_radius, | ||
value_type | rotation = 0.0 |
||
) |
Constructor with all values given.
Constructor with all values given: x/y of center point, x/y of size (where the x coordinate of the size is in the same direction as the x axis of the coordinate system, rotated by the rotation argument; the y coordinate accordingly), and rotation.
x_center | X-coordinate of center point |
y_center | Y-coordinate of center point |
x_radius | The radius of the ellipse in X-direction in the ellipse' coordinate system. Must be non-negative. |
y_radius | The radius of the ellipse in Y-direction in the ellipse' coordinate system. Must be non-negative. |
rotation | The rotation of the ellipse' coordinate system around its center point in [radians]. Must be in the interval [-pi,pi], which can be obtained by using normalizeRadians(). |
Definition at line 37 of file Ellipse2D.cpp.
bool datatypes::Ellipse2D::containsPoint | ( | const Point2D & | point | ) | const |
Returns true if the given Point2D is inside this ellipse or on its outline.
(Note: This function is relatively cheap - it needs two sinus operations, four multiplications and a bunch of comparisons.)
Reimplemented in datatypes::Circle2D.
Definition at line 66 of file Ellipse2D.cpp.
const Point2D& datatypes::Ellipse2D::getCenter | ( | ) | const [inline] |
Returns the center point of this Ellipse.
Definition at line 88 of file Ellipse2D.hpp.
const Point2D& datatypes::Ellipse2D::getRadius | ( | ) | const [inline] |
Returns the radius of this Ellipse.
The returned radius denotes the radius of the ellipse in x-direction Point2D::getX() and y-direction Point2D::getY(), where the x-direction is rotated against the original x-axis by getRotation().
Reimplemented in datatypes::Circle2D.
Definition at line 97 of file Ellipse2D.hpp.
value_type datatypes::Ellipse2D::getRotation | ( | ) | const [inline] |
Returns the rotation angle of this Ellipse2D in [radians], counter clock wise.
The rotation of the ellipse' coordinate system around its center point. Must be in the interval [-pi,pi]
Definition at line 104 of file Ellipse2D.hpp.
virtual const UINT32 datatypes::Ellipse2D::getUsedMemory | ( | ) | const [inline, virtual] |
Implements datatypes::BasicData.
Reimplemented in datatypes::Circle2D.
Definition at line 82 of file Ellipse2D.hpp.
void datatypes::Ellipse2D::setCenter | ( | const Point2D & | p | ) | [inline] |
Sets the center point of this Ellipse2D.
Definition at line 113 of file Ellipse2D.hpp.
void datatypes::Ellipse2D::setCenter | ( | value_type | x, |
value_type | y | ||
) | [inline] |
Sets the center point of this Ellipse2D.
Definition at line 116 of file Ellipse2D.hpp.
void datatypes::Ellipse2D::setRadius | ( | const Point2D & | p | ) |
Sets the radius of this Ellipse. Must be non-negative.
Definition at line 49 of file Ellipse2D.cpp.
void datatypes::Ellipse2D::setRadius | ( | value_type | x_length, |
value_type | y_width | ||
) |
Sets the radius of this Ellipse2D. Must be non-negative.
Definition at line 54 of file Ellipse2D.cpp.
void datatypes::Ellipse2D::setRotation | ( | value_type | r | ) |
Sets the rotation angle of this Ellipse in [radians], counter clock wise.
The rotation of the ellipse' coordinate system around its center point. Must be in the interval [-pi,pi], which can be obtained by using normalizeRadians().
Definition at line 60 of file Ellipse2D.cpp.
std::string datatypes::Ellipse2D::toString | ( | ) | const |
Definition at line 145 of file Ellipse2D.cpp.
void datatypes::Ellipse2D::verifyNumericRanges | ( | ) | [private] |
Definition at line 107 of file Ellipse2D.cpp.
Definition at line 170 of file Ellipse2D.hpp.
Definition at line 161 of file Ellipse2D.hpp.
Point2D datatypes::Ellipse2D::m_center [protected] |
Definition at line 36 of file Ellipse2D.hpp.
Point2D datatypes::Ellipse2D::m_radius [protected] |
Definition at line 37 of file Ellipse2D.hpp.
value_type datatypes::Ellipse2D::m_rotation [protected] |
Definition at line 38 of file Ellipse2D.hpp.