OpenLexocad  27.1
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 #ifndef BASE_ROTATION_H
25 #define BASE_ROTATION_H
26 
27 #include "Vector3D.h"
28 
29 namespace Base {
30 
31 // forward declarations
32 class Matrix4D;
33 
34 class LX_BASE_EXPORT Rotation
35 {
36 public:
39  Rotation();
40  Rotation(const Vector3d& axis, const double fAngle);
41  Rotation(const Matrix4D& matrix);
42  Rotation(const double q[4]);
43  Rotation(const double q0, const double q1, const double q2, const double q3);
44  Rotation(const Vector3d& rotateFrom, const Vector3d& rotateTo);
45  Rotation(const Rotation& rot);
47 
50  const double * getValue(void) const;
51  void getValue(double & q0, double & q1, double & q2, double & q3) const;
52  void setValue(const double q0, const double q1, const double q2, const double q3);
54  void getValue(Vector3d & axis, double & rfAngle) const;
56  void getRawValue(Vector3d & axis, double & rfAngle) const;
57  void getValue(Matrix4D & matrix) const;
58  void setValue(const double q[4]);
59  void setValue(const Matrix4D& matrix);
60  void setValue(const Vector3d & axis, const double fAngle);
61  void setValue(const Vector3d & rotateFrom, const Vector3d & rotateTo);
63  void setYawPitchRoll(double y, double p, double r);
65  void getYawPitchRoll(double& y, double& p, double& r) const;
66  bool isIdentity() const;
67  bool isNull() const;
69 
72  Rotation & invert(void);
73  Rotation inverse(void) const;
75 
78  Rotation & operator*=(const Rotation & q);
79  Rotation operator *(const Rotation & q) const;
80  bool operator==(const Rotation & q) const;
81  bool operator!=(const Rotation & q) const;
82  double & operator [] (unsigned short usIndex){return quat[usIndex];}
83  const double & operator [] (unsigned short usIndex) const{return quat[usIndex];}
84  void operator = (const Rotation&);
85 
86  void multVec(const Vector3d & src, Vector3d & dst) const;
87  Vector3d multVec(const Vector3d & src) const;
88  void scaleAngle(const double scaleFactor);
89  bool isSame(const Rotation&) const;
90  bool isSame(const Rotation&, double tol) const;
92 
94  static Rotation slerp(const Rotation & rot0, const Rotation & rot1, double t);
95  static Rotation identity(void);
96 
111  static Rotation makeRotationByAxes(Vector3d xdir, Vector3d ydir, Vector3d zdir, const char* priorityOrder = "ZXY");
112 
113 private:
114  void normalize();
115  void evaluateVector ();
116  double quat[4];
117  Vector3d _axis; // the axis kept not to lose direction when angle is 0
118  double _angle; // this angle to keep the angle chosen by the user
119 };
120 
121 }
122 
123 #endif // BASE_ROTATION_H
Vector3f & operator *=(Vector3f &rclVect, const Matrix4D &rclMtrx)
Definition: Matrix.h:351
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
Definition: Matrix.h:38
Definition: AbstractXMLReader.h:5
Definition: Rotation.h:34
DualNumber operator *(DualNumber a, DualNumber b)
Definition: DualNumber.h:71