Circle2D.cpp
Go to the documentation of this file.
1 //
2 // Circle2D.cpp
3 //
4 
5 #include <cmath>
6 
7 #include "Circle2D.hpp"
8 #include "../tools/errorhandler.hpp"
9 
10 namespace datatypes
11 {
12 
13 
15  : base_class()
16 {
18 }
19 
20 Circle2D::Circle2D(const Point2D& center, value_type radius)
21  : base_class(center, Point2D(radius, radius), 0)
22 {
24 }
25 
27  : base_class(x_center, y_center, radius, radius, 0)
28 {
30 }
31 
33 {
34  base_class::setRadius(radius, radius);
35 }
36 
37 bool Circle2D::containsPoint(const Point2D& point) const
38 {
39  // Move coordinate system to center of the ellipse
40  value_type deltaX = point.getX() - m_center.getX();
41  value_type deltaY = point.getY() - m_center.getY();
42 
43  // If any of the X or Y components are outside of the radius, the
44  // point cannot be inside the circle.
45  if (std::max(std::abs(deltaX), std::abs(deltaY)) > m_radius.getX())
46  return false;
47 
48  return hypot(deltaX, deltaY) < m_radius.getX();
49 }
50 
51 } // namespace datatypes
52 
Point2D::value_type value_type
The type of the stored x, y coordinates, and the rotation.
Definition: Ellipse2D.hpp:34
value_type getX() const
Definition: Point2D.hpp:70
double hypot(double x, double y, double z)
Definition: MathToolbox.cpp:19
value_type getY() const
Definition: Point2D.hpp:73
A rotated 2-dimensional ellipse in the plane.
Definition: Ellipse2D.hpp:30
void setRadius(const Point2D &p)
Sets the radius of this Ellipse. Must be non-negative.
Definition: Ellipse2D.cpp:49
Circle2D()
Constructor for an all-zero Circle2D.
Definition: Circle2D.cpp:14
bool containsPoint(const Point2D &point) const
Returns true if the given Point2D is inside this ellipse or on its outline.
Definition: Circle2D.cpp:37
void setRadius(value_type radius)
Sets the radius of this circle. Must be non-negative.
Definition: Circle2D.cpp:32


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Sat Jun 8 2019 17:57:33