VR-Forces Development_Version 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) 2016 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;
24  class DtCoordinateConverter;
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 
175  static const double theTimeStep;
176 
178  static const double theGeocentricWaterLineNudge;
179 
180  private:
181  friend struct BuoyancySample;
182 
184  DtVector worldPos(const DtVector& bodyOffset) const;
185 
187  DtTaitBryan worldOri(const DtTaitBryan& bodyOffset) const;
188 
190  DtVector localPos(const DtVector& pos) const;
191 
193  DtTaitBryan localOri(const DtTaitBryan& ori) const;
194 
196  virtual void slot_coordinateSystemChanged();
197 
198  private:
200 
203  {
206  };
207 
209  struct State
210  {
213  DtTaitBryan orientation; // heading, roll, pitch
214  DtTaitBryan rotationalVelocity;
215  };
216 
218  struct Derivative
219  {
220  Derivative();
221  double dz;
222  double dv_z;
223  double dy;
224  double dv_y;
225  double dx;
226  double dv_x;
227  double dpitch;
228  double dv_pitch;
229  double droll;
230  double dv_roll;
231  double dheading;
232  double dv_heading;
233  };
234 
237  {
238  double a_z;
239  double a_y;
240  double a_x;
241  double a_pitch;
242  double a_roll;
243  double a_heading;
244  };
245 
247  Derivative evaluate(const State& initial, double dt, const Derivative& d);
248 
250  Acceleration acceleration(const State& initial, double dt);
251 
255  bool mySinking;
257  double myRollTorque;
261  bool mySinkingFloat[6];
263 
266 
268 
270 
272  };
273 }

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)