src
datatypes
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
14
Circle2D::Circle2D
()
15
:
base_class
()
16
{
17
m_datatype
=
Datatype_Circle2D
;
18
}
19
20
Circle2D::Circle2D
(
const
Point2D
& center,
value_type
radius)
21
:
base_class
(center,
Point2D
(radius, radius), 0)
22
{
23
m_datatype
=
Datatype_Circle2D
;
24
}
25
26
Circle2D::Circle2D
(
value_type
x_center,
value_type
y_center,
value_type
radius)
27
:
base_class
(x_center, y_center, radius, radius, 0)
28
{
29
m_datatype
=
Datatype_Circle2D
;
30
}
31
32
void
Circle2D::setRadius
(
value_type
radius)
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
Circle2D.hpp
datatypes::Point2D
Definition:
Point2D.hpp:27
hypot
double hypot(double x, double y, double z)
Definition:
MathToolbox.cpp:21
datatypes::Ellipse2D::setRadius
void setRadius(const Point2D &p)
Sets the radius of this Ellipse. Must be non-negative.
Definition:
Ellipse2D.cpp:49
datatypes::Circle2D::setRadius
void setRadius(value_type radius)
Sets the radius of this circle. Must be non-negative.
Definition:
Circle2D.cpp:32
datatypes::Point2D::getX
value_type getX() const
Definition:
Point2D.hpp:70
datatypes::BasicData::m_datatype
UINT16 m_datatype
Definition:
BasicDatatypes.hpp:107
datatypes::Circle2D::Circle2D
Circle2D()
Constructor for an all-zero Circle2D.
Definition:
Circle2D.cpp:14
Datatype_Circle2D
@ Datatype_Circle2D
Definition:
BasicDatatypes.hpp:56
datatypes::Ellipse2D
A rotated 2-dimensional ellipse in the plane.
Definition:
Ellipse2D.hpp:30
datatypes::Ellipse2D::value_type
Point2D::value_type value_type
The type of the stored x, y coordinates, and the rotation.
Definition:
Ellipse2D.hpp:34
datatypes::Circle2D::containsPoint
bool containsPoint(const Point2D &point) const
Returns true if the given Point2D is inside this ellipse or on its outline.
Definition:
Circle2D.cpp:37
datatypes::Ellipse2D::m_radius
Point2D m_radius
Definition:
Ellipse2D.hpp:37
datatypes::Ellipse2D::m_center
Point2D m_center
Definition:
Ellipse2D.hpp:36
datatypes::Point2D::getY
value_type getY() const
Definition:
Point2D.hpp:73
datatypes
Definition:
BasicDatatypes.hpp:91
libsick_ldmrs
Author(s): SICK AG
, Martin Günther
, Jochen Sprickerhof
autogenerated on Wed Oct 26 2022 02:11:57