MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
reffrm.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/reffrm.cc,v 1.25 2017/01/12 14:46:10 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 /* Reference frame: structure, handling etc. */
33 
34 #include "mbconfig.h" // This goes first in every *.c,*.cc file
35 
36 #include <iomanip>
37 
38 #include "reffrm.h"
39 #include "Rot.hh"
40 
42 : WithLabel(0),
43 x(::mb_zero<Vec3>()),
44 R(::mb_deye<Mat3x3>(1.)),
45 v(::mb_zero<Vec3>()),
46 w(::mb_zero<Vec3>()),
48 {
49  NO_OP;
50 }
51 
52 ReferenceFrame::ReferenceFrame(unsigned int uLabel,
53  const Vec3& xIn, const Mat3x3& RIn,
54  const Vec3& vIn, const Vec3& wIn,
55  const OrientationDescription& ood)
56 : WithLabel(uLabel), x(xIn), R(RIn), v(vIn), w(wIn), od(ood)
57 {
58  ASSERT(Mat3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.).IsSame(R.MulTM(R), 1e-12));
59 }
60 
62 : WithLabel(0),
63 x(pRBK->GetX()), R(pRBK->GetR()),
64 v(pRBK->GetV()), w(pRBK->GetW()),
65 od(EULER_123)
66 {
67  ASSERT(Eye3.IsSame(R.MulTM(R), 1e-12));
68 }
69 
71  NO_OP;
72 }
73 
74 const Vec3&
76 {
77  return x;
78 }
79 
80 const Mat3x3&
82 {
83  return R;
84 }
85 
86 const Vec3&
88 {
89  return v;
90 }
91 
92 const Vec3&
94 {
95  return w;
96 }
97 
98 const Vec3&
100 {
102 }
103 
104 const Vec3&
106 {
108 }
109 
112 {
113  PutLabel(rf.GetLabel());
114  x = rf.x;
115  R = rf.R;
116  v = rf.v;
117  w = rf.w;
118  od = rf.od;
119  return *this;
120 }
121 
122 std::ostream&
123 ReferenceFrame::Output(std::ostream& out) const
124 {
125  out
126  << std::setw(8) << GetLabel() << " "
127  << x << " ";
128 
129  switch (od) {
130  case EULER_123:
131  out << MatR2EulerAngles123(R)*dRaDegr;
132  break;
133 
134  case EULER_313:
135  out << MatR2EulerAngles313(R)*dRaDegr;
136  break;
137 
138  case EULER_321:
139  out << MatR2EulerAngles321(R)*dRaDegr;
140  break;
141 
142  case ORIENTATION_VECTOR:
143  out << RotManip::VecRot(R);
144  break;
145 
146  case ORIENTATION_MATRIX:
147  out << R;
148  break;
149 
150  default:
152  }
153 
154  return out << " "
155  << v << " " << w << " " << std::endl;
156 }
157 
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Definition: matvec3.h:98
ReferenceFrame(void)
Definition: reffrm.cc:41
const Vec3 & GetV(void) const
Definition: reffrm.cc:87
std::ostream & Output(std::ostream &out) const
Definition: reffrm.cc:123
const Mat3x3 Eye3(1., 0., 0., 0., 1., 0., 0., 0., 1.)
OrientationDescription
Definition: matvec3.h:1597
bool IsSame(const doublereal &d1, const doublereal &d2, const doublereal &dTol)
Definition: matvec3.cc:1138
#define NO_OP
Definition: myassert.h:74
OrientationDescription od
Definition: reffrm.h:53
Vec3 VecRot(const Mat3x3 &Phi)
Definition: Rot.cc:136
~ReferenceFrame(void)
Definition: reffrm.cc:70
Mat3x3 R
Definition: reffrm.h:49
const Mat3x3 & GetR(void) const
Definition: reffrm.cc:81
const Vec3 & GetWP(void) const
Definition: reffrm.cc:105
const T & mb_zero(void)
Vec3 MatR2EulerAngles313(const Mat3x3 &R)
Definition: matvec3.cc:927
const Vec3 & GetX(void) const
Definition: reffrm.cc:75
const Vec3 & GetW(void) const
Definition: reffrm.cc:93
Vec3 MatR2EulerAngles123(const Mat3x3 &R)
Definition: matvec3.cc:893
const doublereal dRaDegr
Definition: matvec3.cc:884
#define ASSERT(expression)
Definition: colamd.c:977
Mat3x3 MulTM(const Mat3x3 &m) const
Definition: matvec3.cc:500
T mb_deye(const doublereal d)
Vec3 MatR2EulerAngles321(const Mat3x3 &R)
Definition: matvec3.cc:941
ReferenceFrame & operator=(const ReferenceFrame &rf)
Definition: reffrm.cc:111
const Vec3 & GetXPP(void) const
Definition: reffrm.cc:99
void PutLabel(unsigned int uL)
Definition: withlab.cc:50
unsigned int GetLabel(void) const
Definition: withlab.cc:62
Mat3x3 R
bool IsSame(const Mat3x3 &m, const doublereal &dTol) const
Definition: matvec3.h:1249