OpenLexocad  28.0
Rotation.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (c) 2006 Werner Mayer <wmayer[at]users.sourceforge.net> *
3  * *
4  * This file is part of the FreeCAD CAx development system. *
5  * *
6  * This library is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Library General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU Library General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Library General Public *
17  * License along with this library; see the file COPYING.LIB. If not, *
18  * write to the Free Software Foundation, Inc., 59 Temple Place, *
19  * Suite 330, Boston, MA 02111-1307, USA *
20  * *
21  ***************************************************************************/
22 
23 
24 #pragma once
25 #include <Base/Vector3D.h>
26 
27 namespace Base {
28 
29 // forward declarations
30 class Matrix4D;
31 
32 class LX_BASE_EXPORT Rotation
33 {
34 public:
37  Rotation();
38  Rotation(const Vector3d& axis, const double fAngle);
39  Rotation(const Matrix4D& matrix);
40  Rotation(const double q[4]);
41  Rotation(const double q0, const double q1, const double q2, const double q3);
42  Rotation(const Vector3d& rotateFrom, const Vector3d& rotateTo);
43  Rotation(const Rotation& rot);
45 
48  const double * getValue(void) const;
49  void getValue(double & q0, double & q1, double & q2, double & q3) const;
50  void setValue(const double q0, const double q1, const double q2, const double q3);
52  void getValue(Vector3d & axis, double & rfAngle) const;
54  void getRawValue(Vector3d & axis, double & rfAngle) const;
55  void getValue(Matrix4D & matrix) const;
56  void setValue(const double q[4]);
57  void setValue(const Matrix4D& matrix);
58  void setValue(const Vector3d & axis, const double fAngle);
59  void setValue(const Vector3d & rotateFrom, const Vector3d & rotateTo);
61  void setYawPitchRoll(double y, double p, double r);
63  void getYawPitchRoll(double& y, double& p, double& r) const;
64  bool isIdentity() const;
65  bool isNull() const;
67 
70  Rotation & invert(void);
71  Rotation inverse(void) const;
73 
77  Rotation operator *(const Rotation & q) const;
78  bool operator==(const Rotation & q) const;
79  bool operator!=(const Rotation & q) const;
80  double & operator [] (unsigned short usIndex){return quat[usIndex];}
81  const double & operator [] (unsigned short usIndex) const{return quat[usIndex];}
82  void operator = (const Rotation&);
83 
84  void multVec(const Vector3d & src, Vector3d & dst) const;
85  Vector3d multVec(const Vector3d & src) const;
86  void scaleAngle(const double scaleFactor);
87  bool isSame(const Rotation&) const;
88  bool isSame(const Rotation&, double tol) const;
90 
92  static Rotation slerp(const Rotation & rot0, const Rotation & rot1, double t);
93  static Rotation identity(void);
94 
109  static Rotation makeRotationByAxes(Vector3d xdir, Vector3d ydir, Vector3d zdir, const char* priorityOrder = "ZXY");
110 
111 private:
112  void normalize();
113  void evaluateVector ();
114  double quat[4];
115  Vector3d _axis; // the axis kept not to lose direction when angle is 0
116  double _angle; // this angle to keep the angle chosen by the user
117 };
118 
119 }
Base::operator*=
Vector3f & operator*=(Vector3f &rclVect, const Matrix4D &rclMtrx)
Definition: Matrix.h:367
Base::Vector3< double >
Base::Vector3d
Vector3< double > Vector3d
Definition: Vector3D.h:246
Base::operator*
DualNumber operator*(DualNumber a, DualNumber b)
Definition: DualNumber.h:91
entt::operator!=
constexpr bool operator!=(const basic_hashed_string< Char > &lhs, const basic_hashed_string< Char > &rhs) ENTT_NOEXCEPT
Compares two hashed strings.
Definition: entt.hpp:570
Base::Rotation
Definition: Rotation.h:53
Vector3D.h
Base::Matrix4D
Definition: Matrix.h:55
Base
Definition: AbstractXMLReader.h:5