MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
posrel.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/posrel.h,v 1.18 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 #ifndef POSREL_H
33 #define POSREL_H
34 
35 #include <strnode.h>
36 #include <submat.h>
37 #include <drive.h>
38 
39 /* Posizione relativa
40  * contiene un riferimento ad un nodo strutturale
41  * ed una posizione relativa rispetto a questo, piu' gli strumenti
42  * per passare alla posizione ed alal velocita' nel sistema assoluto
43  * (rotazione) ed in quello globale (traslazione del nodo).
44  * In pratica un punto nel sistema locale di un nodo.
45  * E' una classe virtuale pura, in quanto la posizione locale e' definita
46  * attraverso un metodo virtuale puro che ritorna un vettore 3x1.
47  * Sono definite contestualmente le classi derivate di:
48  *
49  * - posizione costante
50  * - direzione fissa (usa un drive per la distanza dal nodo)
51  *
52  * Sviluppi possibili:
53  * - TplDrive<Vec3>
54  * - ...
55  *
56  * Occorre modificare gli elementi ed i reference per usare queste distanze
57  * in modo uniforme e consistente.
58  */
59 
60 
61 /* PosRel - begin */
62 
63 class PosRel {
64  protected:
66 
67  public:
69  virtual ~PosRel(void);
70 
71  inline const StructNode* pGetNode(void) const;
72 
73  virtual const Vec3& GetPosRel(void) const = 0;
74 
75  virtual inline const Vec3& GetPosAbs(void) const;
76  virtual inline const Vec3& GetPosGlob(void) const;
77  virtual inline const Vec3& GetVelAbs(void) const;
78  virtual inline const Vec3& GetVelGlob(void) const;
79 };
80 
81 inline const StructNode* PosRel::pGetNode(void) const
82 {
83  return pNode;
84 }
85 
86 inline const StructNode* PosRel::GetPosAbs(void) const
87 {
88  return pNode->GetRCurr()*GetPosRel();
89 }
90 
91 inline const StructNode* PosRel::GetPosGlob(void) const
92 {
93  return pNode->GetXCurr()+pNode->GetRCurr()*GetPosRel();
94 }
95 
96 inline const StructNode* PosRel::GetVelAbs(void) const
97 {
98  return pNode->GetWCurr().Cross(pNode->GetRCurr()*GetPosRel());
99 }
100 
101 inline const StructNode* PosRel::GetVelGlob(void) const
102 {
103  return pNode->GetVCurr()
105 }
106 
107 /* PosRel - end */
108 
109 
110 /* ConstPosRel - begin */
111 
112 class ConstPosRel : public PosRel {
113  protected:
115  public:
116  ConstPosRel(StructNode* pNode, const Vec3& d);
117  virtual ~ConstPosRel(void);
118 
119  virtual inline const Vec3& GetPosRel(void) const;
120 };
121 
122 inline const Vec3& ConstPosRel::GetPosRel(void) const
123 {
124  return d;
125 }
126 
127 /* ConstPosRel - end */
128 
129 
130 /* FixedDirPosRel - begin */
131 
132 class FixedDirPosRel : public PosRel {
133  protected:
136 
137  public:
138  FixedDirPosRel(StructNode* pNode, const Vec3& v, const DriveCaller* pDC);
139  virtual ~FixedDirPosRel(void);
140 
141  virtual inline const Vec3& GetPosRel(void) const;
142 };
143 
144 inline const Vec3& FixedDirPosRel::GetPosRel(void) const
145 {
146  return v*d.dGet();
147 }
148 
149 /* FixedDirPosRel - end */
150 
151 #endif /* POSREL_H */
virtual const Vec3 & GetVelGlob(void) const
Definition: posrel.h:101
Vec3 Cross(const Vec3 &v) const
Definition: matvec3.h:218
Definition: matvec3.h:98
PosRel(StructNode *pNode)
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
virtual ~FixedDirPosRel(void)
Vec3 d
Definition: posrel.h:114
virtual const Vec3 & GetVelAbs(void) const
Definition: posrel.h:96
virtual ~PosRel(void)
virtual const Vec3 & GetPosRel(void) const =0
virtual const Vec3 & GetPosAbs(void) const
Definition: posrel.h:86
Definition: posrel.h:63
FixedDirPosRel(StructNode *pNode, const Vec3 &v, const DriveCaller *pDC)
StructNode * pNode
Definition: posrel.h:65
virtual const Vec3 & GetPosRel(void) const
Definition: posrel.h:144
virtual const Vec3 & GetWCurr(void) const
Definition: strnode.h:1030
const StructNode * pGetNode(void) const
Definition: posrel.h:81
virtual const Vec3 & GetXCurr(void) const
Definition: strnode.h:310
virtual ~ConstPosRel(void)
virtual const Vec3 & GetPosRel(void) const
Definition: posrel.h:122
ConstPosRel(StructNode *pNode, const Vec3 &d)
doublereal dGet(const doublereal &dVar) const
Definition: drive.cc:664
virtual const Vec3 & GetPosGlob(void) const
Definition: posrel.h:91
virtual const Vec3 & GetVCurr(void) const
Definition: strnode.h:322
DriveOwner d
Definition: posrel.h:135