Circle2D.cpp
Go to the documentation of this file.
00001 //
00002 // Circle2D.cpp
00003 //
00004 
00005 #include <cmath>
00006 
00007 #include "Circle2D.hpp"
00008 #include "../tools/errorhandler.hpp"
00009 
00010 namespace datatypes
00011 {
00012 
00013 
00014 Circle2D::Circle2D()
00015         : base_class()
00016 {
00017         m_datatype = Datatype_Circle2D;
00018 }
00019 
00020 Circle2D::Circle2D(const Point2D& center, value_type radius)
00021         : base_class(center, Point2D(radius, radius), 0)
00022 {
00023         m_datatype = Datatype_Circle2D;
00024 }
00025 
00026 Circle2D::Circle2D(value_type x_center, value_type y_center, value_type radius)
00027         : base_class(x_center, y_center, radius, radius, 0)
00028 {
00029         m_datatype = Datatype_Circle2D;
00030 }
00031 
00032 void Circle2D::setRadius(value_type radius)
00033 {
00034         base_class::setRadius(radius, radius);
00035 }
00036 
00037 bool Circle2D::containsPoint(const Point2D& point) const
00038 {
00039         // Move coordinate system to center of the ellipse
00040         value_type deltaX = point.getX() - m_center.getX();
00041         value_type deltaY = point.getY() - m_center.getY();
00042 
00043         // If any of the X or Y components are outside of the radius, the
00044         // point cannot be inside the circle.
00045         if (std::max(std::abs(deltaX), std::abs(deltaY)) > m_radius.getX())
00046                 return false;
00047 
00048         return hypot(deltaX, deltaY) < m_radius.getX();
00049 }
00050 
00051 }       // namespace datatypes
00052 


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Thu Jun 6 2019 21:02:36