KiCad PCB EDA Suite
Loading...
Searching...
No Matches
transform_trs.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 The 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
#ifndef TRANSFORM_TRS_H
21
#define TRANSFORM_TRS_H
22
23
#include <
math/vector2d.h
>
24
#include <
geometry/eda_angle.h
>
25
26
27
// Translate / rotate / scale transform for footprint placement.
28
// Apply order is fixed: scale, then rotate, then translate.
29
// Independent X/Y scale is allowed. Shear is not representable.
30
class
TRANSFORM_TRS
31
{
32
public
:
33
TRANSFORM_TRS
() :
34
m_translate
( 0, 0 ),
35
m_rotate
(
ANGLE_0
),
36
m_scaleX
( 1.0 ),
37
m_scaleY
( 1.0 )
38
{}
39
40
TRANSFORM_TRS
(
const
VECTOR2I
& aTranslate,
const
EDA_ANGLE
& aRotate,
41
double
aScaleX,
double
aScaleY ) :
42
m_translate
( aTranslate ),
43
m_rotate
( aRotate ),
44
m_scaleX
( aScaleX ),
45
m_scaleY
( aScaleY )
46
{}
47
48
VECTOR2I
Apply
(
const
VECTOR2I
& aPoint )
const
;
49
VECTOR2D
Apply
(
const
VECTOR2D
& aPoint )
const
;
50
51
VECTOR2I
InverseApply
(
const
VECTOR2I
& aPoint )
const
;
52
VECTOR2D
InverseApply
(
const
VECTOR2D
& aPoint )
const
;
53
54
TRANSFORM_TRS
Invert
()
const
;
55
56
TRANSFORM_TRS
Compose
(
const
TRANSFORM_TRS
& aOuter )
const
;
57
58
TRANSFORM_TRS
RescaleAround
(
const
VECTOR2I
& aFixedPoint,
double
aSx,
double
aSy )
const
;
59
60
bool
IsIdentity
()
const
;
61
bool
IsUniformScale
()
const
;
62
63
double
ApplyLinearScale
(
double
aLength )
const
;
64
65
const
VECTOR2I
&
GetTranslate
()
const
{
return
m_translate
; }
66
const
EDA_ANGLE
&
GetRotate
()
const
{
return
m_rotate
; }
67
double
GetScaleX
()
const
{
return
m_scaleX
; }
68
double
GetScaleY
()
const
{
return
m_scaleY
; }
69
70
void
SetTranslate
(
const
VECTOR2I
& aT ) {
m_translate
= aT; }
71
void
SetRotate
(
const
EDA_ANGLE
& aR ) {
m_rotate
= aR; }
72
void
SetScale
(
double
aSx,
double
aSy ) {
m_scaleX
= aSx;
m_scaleY
= aSy; }
73
74
bool
operator==
(
const
TRANSFORM_TRS
& aOther )
const
;
75
bool
operator!=
(
const
TRANSFORM_TRS
& aOther )
const
{
return
!( *
this
== aOther ); }
76
77
private
:
78
VECTOR2I
m_translate
;
79
EDA_ANGLE
m_rotate
;
80
double
m_scaleX
;
81
double
m_scaleY
;
82
};
83
84
#endif
// TRANSFORM_TRS_H
EDA_ANGLE
Definition
eda_angle.h:37
TRANSFORM_TRS
Definition
transform_trs.h:31
TRANSFORM_TRS::InverseApply
VECTOR2I InverseApply(const VECTOR2I &aPoint) const
Definition
transform_trs.cpp:47
TRANSFORM_TRS::Compose
TRANSFORM_TRS Compose(const TRANSFORM_TRS &aOuter) const
Definition
transform_trs.cpp:69
TRANSFORM_TRS::m_scaleX
double m_scaleX
Definition
transform_trs.h:80
TRANSFORM_TRS::TRANSFORM_TRS
TRANSFORM_TRS(const VECTOR2I &aTranslate, const EDA_ANGLE &aRotate, double aScaleX, double aScaleY)
Definition
transform_trs.h:40
TRANSFORM_TRS::IsUniformScale
bool IsUniformScale() const
Definition
transform_trs.cpp:113
TRANSFORM_TRS::Invert
TRANSFORM_TRS Invert() const
Definition
transform_trs.cpp:54
TRANSFORM_TRS::GetRotate
const EDA_ANGLE & GetRotate() const
Definition
transform_trs.h:66
TRANSFORM_TRS::GetScaleX
double GetScaleX() const
Definition
transform_trs.h:67
TRANSFORM_TRS::SetTranslate
void SetTranslate(const VECTOR2I &aT)
Definition
transform_trs.h:70
TRANSFORM_TRS::Apply
VECTOR2I Apply(const VECTOR2I &aPoint) const
Definition
transform_trs.cpp:32
TRANSFORM_TRS::m_rotate
EDA_ANGLE m_rotate
Definition
transform_trs.h:79
TRANSFORM_TRS::GetScaleY
double GetScaleY() const
Definition
transform_trs.h:68
TRANSFORM_TRS::ApplyLinearScale
double ApplyLinearScale(double aLength) const
Definition
transform_trs.cpp:119
TRANSFORM_TRS::m_scaleY
double m_scaleY
Definition
transform_trs.h:81
TRANSFORM_TRS::RescaleAround
TRANSFORM_TRS RescaleAround(const VECTOR2I &aFixedPoint, double aSx, double aSy) const
Definition
transform_trs.cpp:80
TRANSFORM_TRS::operator==
bool operator==(const TRANSFORM_TRS &aOther) const
Definition
transform_trs.cpp:125
TRANSFORM_TRS::TRANSFORM_TRS
TRANSFORM_TRS()
Definition
transform_trs.h:33
TRANSFORM_TRS::SetScale
void SetScale(double aSx, double aSy)
Definition
transform_trs.h:72
TRANSFORM_TRS::IsIdentity
bool IsIdentity() const
Definition
transform_trs.cpp:104
TRANSFORM_TRS::m_translate
VECTOR2I m_translate
Definition
transform_trs.h:78
TRANSFORM_TRS::SetRotate
void SetRotate(const EDA_ANGLE &aR)
Definition
transform_trs.h:71
TRANSFORM_TRS::GetTranslate
const VECTOR2I & GetTranslate() const
Definition
transform_trs.h:65
TRANSFORM_TRS::operator!=
bool operator!=(const TRANSFORM_TRS &aOther) const
Definition
transform_trs.h:75
eda_angle.h
ANGLE_0
static constexpr EDA_ANGLE ANGLE_0
Definition
eda_angle.h:411
vector2d.h
VECTOR2I
VECTOR2< int32_t > VECTOR2I
Definition
vector2d.h:683
VECTOR2D
VECTOR2< double > VECTOR2D
Definition
vector2d.h:682
src
libs
kimath
include
geometry
transform_trs.h
Generated on Fri Jun 26 2026 00:05:37 for KiCad PCB EDA Suite by
1.13.2