KiCad PCB EDA Suite
Loading...
Searching...
No Matches
circle.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2021 Roberto Fernandez Bautista <[email protected]>
5 * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef __CIRCLE_H
22#define __CIRCLE_H
23
24#include <math/vector2d.h> // for VECTOR2I
25#include <vector> // for std::vector
26
27class SEG;
28
32class CIRCLE
33{
34public:
35 CIRCLE();
36
37 CIRCLE( const VECTOR2I& aCenter, int aRadius );
38
39 CIRCLE( const CIRCLE& aOther );
40
41 bool operator==( const CIRCLE& aOther ) const = default;
42
57 CIRCLE& ConstructFromTanTanPt( const SEG& aLineA, const SEG& aLineB, const VECTOR2I& aP );
58
66 bool Contains( const VECTOR2I& aP ) const;
67
77 VECTOR2I NearestPoint( const VECTOR2I& aP ) const;
78
89 VECTOR2D NearestPoint( const VECTOR2D& aP ) const;
90
100 std::vector<VECTOR2I> Intersect( const CIRCLE& aCircle ) const;
101
108 std::vector<VECTOR2I> Intersect( const SEG& aSeg ) const;
109
119 std::vector<VECTOR2I> IntersectLine( const SEG& aLine ) const;
120
127 bool Contains( const VECTOR2I& aP );
128
129 int Radius;
131};
132
133#endif // __CIRCLE_H
134
Represent basic circle geometry with utility geometry functions.
Definition: circle.h:33
VECTOR2I Center
Public to make access simpler.
Definition: circle.h:130
bool operator==(const CIRCLE &aOther) const =default
int Radius
Public to make access simpler.
Definition: circle.h:129
std::vector< VECTOR2I > Intersect(const CIRCLE &aCircle) const
Compute the intersection points between this circle and aCircle.
Definition: circle.cpp:221
CIRCLE()
Definition: circle.cpp:30
std::vector< VECTOR2I > IntersectLine(const SEG &aLine) const
Compute the intersection points between this circle and aLine.
Definition: circle.cpp:300
CIRCLE & ConstructFromTanTanPt(const SEG &aLineA, const SEG &aLineB, const VECTOR2I &aP)
Construct this circle such that it is tangent to the given segments and passes through the given poin...
Definition: circle.cpp:51
VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute the point on the circumference of the circle that is the closest to aP.
Definition: circle.cpp:197
bool Contains(const VECTOR2I &aP) const
Return true if aP is on the circumference of this circle.
Definition: circle.cpp:188
Definition: seg.h:42