mbsim  4.0.0
MBSim Kernel
rotation_about_axes_zyx_transformed_mapping.h
1 /* Copyright (C) 2004-2009 MBSim Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact: martin.o.foerg@gmail.com
18  */
19 
20 #ifndef _ROTATION_ABOUT_AXES_ZYX_TRANSFORMED_MAPPING_H_
21 #define _ROTATION_ABOUT_AXES_ZYX_TRANSFORMED_MAPPING_H_
22 
23 #include "mbsim/functions/function.h"
24 
25 namespace MBSim {
26 
27  template<class Arg>
28  class RotationAboutAxesZYXTransformedMapping : public Function<fmatvec::MatV(Arg)> {
29  private:
30  fmatvec::MatV T;
31  public:
32  RotationAboutAxesZYXTransformedMapping() : T(3,3) { T.e(2,0) = 1; }
33  int getArgSize() const override { return 3; }
34  fmatvec::MatV operator()(const Arg &q) override {
35  double beta = q.e(1);
36  double gamma = q.e(2);
37  double cos_beta = cos(beta);
38  if(fabs(cos_beta)<=1e-13)
39  Element::throwError("Singularity in rotation.");
40  double sin_beta = sin(beta);
41  double cos_gamma = cos(gamma);
42  double sin_gamma = sin(gamma);
43  double tan_beta = sin_beta/cos_beta;
44  T.e(0,1) = sin_gamma/cos_beta;
45  T.e(0,2) = cos_gamma/cos_beta;
46  T.e(1,1) = cos_gamma;
47  T.e(1,2) = -sin_gamma;
48  T.e(2,1) = tan_beta*sin_gamma;
49  T.e(2,2) = tan_beta*cos_gamma;
50  return T;
51  }
52  };
53 
54 }
55 
56 #endif
Definition: rotation_about_axes_zyx_transformed_mapping.h:28
Definition: contact_kinematics.h:32
namespace MBSim
Definition: eigenanalyzer.cc:47