VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtRk4MotionModel.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvTriton/vrvTriton.h>
13 
15 
16 #include <matrix/vlVector.h>
17 #include <matrix/vlTaitBryan.h>
18 
19 namespace makVrv
20 {
21  class DtTritonManager;
22  class Dt3DLineModelInstanceSegment;
23  class DtDe;
25 
32  {
33  public:
36 
38  virtual ~DtRk4MotionModel();
39 
44  void tick(double dt);
45 
47  DtVector velocity() const;
48 
50  DtVector position() const;
51 
53  DtTaitBryan orientation() const;
54 
56  void setPosition(const DtVector& position);
57 
59  void setOrientation(const DtTaitBryan& orientation);
60 
62  void setTargetOrientation(const DtTaitBryan& orientation);
63 
67  void setSpeed(double speed);
68 
70  void sink();
71 
73  void unsink();
74 
76  bool isSinking();
77 
79  void setSinkingSpeedScale( double scale );
80 
82  double sinkingSpeedScale() const;
83 
85  void setRotationalInertia(double pitchInertia, double rollInertia);
86 
88  void applyForce(const DtVector& offset, const DtVector& force);
89 
91  void applyHeadingTorque(double magnitude);
92 
94  void applyRollTorque(double magnitude);
95 
100  {
105  BuoyancySample(DtDe& de, DtVector offset, double area, double extent, double density, double waterline);
106 
111  double computeForce(const DtVector& pos, const DtVector& vel, const DtDcm& ori);
112 
117  double computeFlatForce(const DtVector& pos, const DtVector& vel, const DtTaitBryan& ori);
118 
121 
123  double myExtent;
124 
126  double myDensity;
127 
129  double myArea;
130 
132  double myWaterline;
133 
138 
141 
144 #if 0
145  enum ImpactState
146  {
147  AboveWater,
148  BelowWater,
149  Impacted
150  };
151  ImpactState myImpactState; // whether sample went from above to below water surface last frame
152 #endif
153  };
154 
157 
158  typedef std::vector<BuoyancySample*> BuoyancySampleVec;
159 
162 
166  void setOrigin(const DtVector& pos);
167 
169  DtVector origin() const;
170 
172  void moveOrigin(const DtVector& pos);
173 
174  private:
175  friend struct BuoyancySample;
176 
178  DtVector worldPos(const DtVector& bodyOffset) const;
179 
181  DtTaitBryan worldOri(const DtTaitBryan& bodyOffset) const;
182 
184  DtVector localPos(const DtVector& pos) const;
185 
187  DtTaitBryan localOri(const DtTaitBryan& ori) const;
188 
190  virtual void slot_coordinateSystemChanged();
191 
192  private:
194 
197  {
200  };
201 
203  struct State
204  {
207  DtTaitBryan orientation; // heading, roll, pitch
208  DtTaitBryan rotationalVelocity;
209  };
210 
212  struct Derivative
213  {
214  Derivative();
215  double dz;
216  double dv_z;
217  double dy;
218  double dv_y;
219  double dx;
220  double dv_x;
221  double dpitch;
222  double dv_pitch;
223  double droll;
224  double dv_roll;
225  double dheading;
226  double dv_heading;
227  };
228 
231  {
232  double a_z;
233  double a_y;
234  double a_x;
235  double a_pitch;
236  double a_roll;
237  double a_heading;
238  };
239 
241  Derivative evaluate(const State& initial, double dt, const Derivative& d);
242 
244  Acceleration acceleration(const State& initial, double dt);
245 
249  bool mySinking;
251  double myRollTorque;
255  bool mySinkingFloat[6];
257 
260 
262 
264 
266  };
267 }

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)