KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eda_angle.cpp
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-2022 KiCad Developers, see AUTHORS.txt for contributors.
5
*
6
* This program is free software: you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License as published by the
8
* Free Software Foundation, either version 3 of the License, or (at your
9
* option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along
17
* with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#include <
geometry/eda_angle.h
>
21
22
23
EDA_ANGLE
EDA_ANGLE::KeepUpright
()
const
24
{
25
EDA_ANGLE
inAngle( *
this
);
26
inAngle.
Normalize
();
27
28
double
inDegrees = inAngle.
AsDegrees
();
29
double
outDegrees;
30
31
if
( inDegrees <= 45 || inDegrees >= 315 || ( inDegrees > 135 && inDegrees <= 225 ) )
32
outDegrees = 0;
33
else
34
outDegrees = 90;
35
36
return
EDA_ANGLE
( outDegrees,
DEGREES_T
);
37
}
38
39
40
bool
EDA_ANGLE::IsCardinal
()
const
41
{
42
double
test
=
m_value
;
43
44
while
(
test
< 0.0 )
45
test
+= 90.0;
46
47
while
(
test
>= 90.0 )
48
test
-= 90.0;
49
50
return
test
== 0.0;
51
}
52
53
54
bool
EDA_ANGLE::IsCardinal90
()
const
55
{
56
// return true if angle is one of the two cardinal directions (90/270 degrees),
57
double
test
=
std::abs
(
m_value
);
58
59
while
(
test
>= 180.0 )
60
test
-= 180.0;
61
62
return
test
== 90.0;
63
}
EDA_ANGLE
Definition:
eda_angle.h:37
EDA_ANGLE::Normalize
EDA_ANGLE Normalize()
Definition:
eda_angle.h:221
EDA_ANGLE::AsDegrees
double AsDegrees() const
Definition:
eda_angle.h:113
EDA_ANGLE::IsCardinal
bool IsCardinal() const
Definition:
eda_angle.cpp:40
EDA_ANGLE::KeepUpright
EDA_ANGLE KeepUpright() const
Definition:
eda_angle.cpp:23
EDA_ANGLE::EDA_ANGLE
EDA_ANGLE()
Definition:
eda_angle.h:109
EDA_ANGLE::IsCardinal90
bool IsCardinal90() const
Definition:
eda_angle.cpp:54
EDA_ANGLE::m_value
double m_value
value in degrees
Definition:
eda_angle.h:305
eda_angle.h
DEGREES_T
@ DEGREES_T
Definition:
eda_angle.h:31
std::abs
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition:
eda_angle.h:390
test
Definition:
drc_test_provider_diff_pair_coupling.cpp:51
src
libs
kimath
src
geometry
eda_angle.cpp
Generated on Sun Dec 22 2024 00:05:25 for KiCad PCB EDA Suite by
1.9.6