mbsim  4.0.0
MBSim Kernel
rotation_about_axes_xz.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_XZ_H_
21#define _ROTATION_ABOUT_AXES_XZ_H_
22
23#include "mbsim/functions/function.h"
24
25namespace MBSim {
26
27 template<class Arg>
28 class RotationAboutAxesXZ : public Function<fmatvec::RotMat3(Arg)> {
29 using B = fmatvec::Function<fmatvec::RotMat3(Arg)>;
30 private:
31 fmatvec::RotMat3 A;
32 fmatvec::Mat3xV J, Jd;
33 public:
34 RotationAboutAxesXZ() : J(2), Jd(2) { J.e(0,0) = 1; }
35 int getArgSize() const override { return 2; }
36 fmatvec::RotMat3 operator()(const Arg &q) override {
37 double a=q.e(0);
38 double b=q.e(1);
39 double cosa = cos(a);
40 double sina = sin(a);
41 double cosb = cos(b);
42 double sinb = sin(b);
43
44 A.e(0,0) = cosb;
45 A.e(1,0) = cosa*sinb;
46 A.e(2,0) = sina*sinb;
47 A.e(0,1) = -sinb;
48 A.e(1,1) = cosa*cosb;
49 A.e(2,1) = sina*cosb;
50 A.e(1,2) = -sina;
51 A.e(2,2) = cosa;
52
53 return A;
54 }
55 typename B::DRetDArg parDer(const Arg &q) override {
56 double a = q.e(0);
57 J.e(1,1) = -sin(a);
58 J.e(2,1) = cos(a);
59 return J;
60 }
61 typename B::DRetDArg parDerDirDer(const Arg &qd, const Arg &q) override {
62 double a = q.e(0);
63 double ad = qd.e(0);
64 Jd.e(1,1) = -cos(a)*ad;
65 Jd.e(2,1) = -sin(a)*ad;
66 return Jd;
67 }
68 };
69
70}
71
72#endif
Definition: function.h:53
Definition: rotation_about_axes_xz.h:28
namespace MBSim
Definition: bilateral_constraint.cc:30