Debian Codegraph @

src/Base/Axis.cpp

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2
3 /***************************************************************************
4 * Copyright (c) 2011 Jürgen Riegel <[email protected]> *
5 * *
6 * This file is part of the FreeCAD CAx development system. *
7 * *
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Library General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Library General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Library General Public *
19 * License along with this library; see the file COPYING.LIB. If not, *
20 * write to the Free Software Foundation, Inc., 59 Temple Place, *
21 * Suite 330, Boston, MA 02111-1307, USA *
22 * *
23 ***************************************************************************/
24
25 #include "Axis.h"
26 #include "Placement.h"
27
28 using namespace Base;
29
30 Axis::Axis(const Vector3d& Orig, const Vector3d& Dir)
31 : _base {Orig}
32 , _dir {Dir}
33 {}
34
35 void Axis::reverse()
36 {
37 this->_dir = -this->_dir;
38 }
39
40 Axis Axis::reversed() const
41 {
42 Axis axis(*this);
43 axis.reverse();
44 return axis;
45 }
46
47 void Axis::move(const Vector3d& MovVec)
48 {
49 _base += MovVec;
50 }
51
52 bool Axis::operator==(const Axis& that) const
53 {
54 return (this->_base == that._base) && (this->_dir == that._dir);
55 }
56
57 bool Axis::operator!=(const Axis& that) const
58 {
59 return !(*this == that);
60 }
61
62 Axis& Axis::operator*=(const Placement& plm)
63 {
64 plm.multVec(this->_base, this->_base);
65 plm.getRotation().multVec(this->_dir, this->_dir);
66 return *this;
67 }
68
69 Axis Axis::operator*(const Placement& plm) const
70 {
71 Axis axis(*this);
72 axis *= plm;
73 return axis;
74 }