VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 }
Defines a buoyancy sample point.
Definition: DtRk4MotionModel.h:99
double a_z
Definition: DtRk4MotionModel.h:238
bool myIsGeocentric
Flag to decide whether to do magic hacks during force computation.
Definition: DtRk4MotionModel.h:143
bool mySinking
Definition: DtRk4MotionModel.h:255
void applyForce(const DtVector &offset, const DtVector &force)
apply a force at offset (in entity coordinatess) for the next frame
Dt3DLineModelInstanceSegment * myDebugLine[8]
Definition: DtRk4MotionModel.h:253
double myRollInertia
Definition: DtRk4MotionModel.h:264
double myPitchInertia
Definition: DtRk4MotionModel.h:265
void setSpeed(double speed)
Set the forward speed of the object.
double dv_y
Definition: DtRk4MotionModel.h:224
void setSinkingSpeedScale(double scale)
Allow the user to vary the speed at which ships sink.
DtVector origin() const
Get the origin of the simulation&#39;s topo system in world coordinates.
Implementation of a buoyancy model using RK4 integration.
Definition: DtRk4MotionModel.h:31
DtCoordinateConverter is the base class for &#39;local (cig) to geocentric&#39; converters.
Definition: DtCoordinateConverter.h:25
void setOrigin(const DtVector &pos)
Set an origin point in world coordinates for the simulation to use for its topo coordinate system...
BuoyancySample & operator=(const BuoyancySample &obj)
Assignment operator.
double dv_pitch
Definition: DtRk4MotionModel.h:228
double mySinkingSpeedScale
Definition: DtRk4MotionModel.h:262
double dv_x
Definition: DtRk4MotionModel.h:226
void setPosition(const DtVector &position)
Set the object&#39;s position in world coordinates.
double dv_heading
Definition: DtRk4MotionModel.h:232
BuoyancySample(DtDe &de, DtVector offset, double area, double extent, double density, double waterline)
CTOR.
DtTaitBryan orientation
Definition: DtRk4MotionModel.h:213
virtual ~DtRk4MotionModel()
DTOR.
DtVector position() const
Get the object&#39;s position in world coordinates.
double myForwardSpeed
Definition: DtRk4MotionModel.h:259
void addBuoyancySample(BuoyancySample *bs)
Add a buoyancy sample point to the simulated object.
Motion state of the simulation.
Definition: DtRk4MotionModel.h:209
double myWaterline
Z offset to the waterline.
Definition: DtRk4MotionModel.h:132
double mySinkingDensity
Definition: DtRk4MotionModel.h:260
bool mySinkingFloat[6]
Definition: DtRk4MotionModel.h:261
DtVector worldPos(const DtVector &bodyOffset) const
Convert local position offset into world position.
DtVector position
Definition: DtRk4MotionModel.h:211
double myRollTorque
Definition: DtRk4MotionModel.h:257
bool isSinking()
Returns whether the model is currently sinking.
BuoyancySampleVec myBuoyancySamples
Definition: DtRk4MotionModel.h:271
static const double theGeocentricWaterLineNudge
adjustment for geocentric terrains for all buoyant objects.
Definition: DtRk4MotionModel.h:178
double myWaterAltitude
Altitude of water at this sample&#39;s position; should be updated as needed.
Definition: DtRk4MotionModel.h:140
BuoyancySampleVec & buoyancySamples()
Get a list of the sample points.
void applyRollTorque(double magnitude)
Apply a torque around the forward vector for the next frame.
double sinkingSpeedScale() const
Get the current sinking speed scale.
Contains DLL export macros.
DtRk4MotionModel(makVrv::DtDe &de)
CTOR.
void setOrientation(const DtTaitBryan &orientation)
Set the object&#39;s orientation in world coordinates.
double dy
Definition: DtRk4MotionModel.h:223
DtTaitBryan localOri(const DtTaitBryan &ori) const
Convert world orientation into local hrp.
virtual void slot_coordinateSystemChanged()
Update the cached coordinate converter.
double dz
Definition: DtRk4MotionModel.h:221
DtVector myOffset
Offset from object origin in object coordinates.
Definition: DtRk4MotionModel.h:135
void sink()
Start simulated sinking.
double dpitch
Definition: DtRk4MotionModel.h:227
DtVector localPos(const DtVector &pos) const
Convert world position offset into local position.
Acceleration acceleration(const State &initial, double dt)
Compute the second derivatives for the passed in motion state over time step dt.
double a_x
Definition: DtRk4MotionModel.h:240
double dv_z
Definition: DtRk4MotionModel.h:222
friend struct BuoyancySample
Definition: DtRk4MotionModel.h:181
static const double theTimeStep
time step for the motion model in seconds (currently 1/60 of a second)
Definition: DtRk4MotionModel.h:175
double a_heading
Definition: DtRk4MotionModel.h:243
AppliedForce myAppliedForce
Definition: DtRk4MotionModel.h:252
DtVector force
Definition: DtRk4MotionModel.h:205
double computeFlatForce(const DtVector &pos, const DtVector &vel, const DtTaitBryan &ori)
Compute the net force along the object&#39;s up vector at the sample point, assuming a flat water surface...
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:24
DtVector myOriginPos
Definition: DtRk4MotionModel.h:267
double myHeadingTorque
Definition: DtRk4MotionModel.h:256
DtVector velocity
Definition: DtRk4MotionModel.h:212
DtTaitBryan worldOri(const DtTaitBryan &bodyOffset) const
Convert local pitch/roll offset into world orientation.
void tick(double dt)
Tick the physics simulation.
double dheading
Definition: DtRk4MotionModel.h:231
void setTargetOrientation(const DtTaitBryan &orientation)
Set the resting orientation of the object in world coordinates.
void unsink()
Restore the object to the water surface.
std::vector< BuoyancySample * > BuoyancySampleVec
Definition: DtRk4MotionModel.h:158
double dx
Definition: DtRk4MotionModel.h:225
DtTaitBryan orientation() const
Get the object&#39;s orientation in world coordinates.
State myState
Definition: DtRk4MotionModel.h:254
double myArea
Area of the sample in m^2.
Definition: DtRk4MotionModel.h:129
void moveOrigin(const DtVector &pos)
Move the origin of the simulation&#39;s topo system to a new origin, in world coordinates.
double myExtent
Depth extent of the sample point in meters.
Definition: DtRk4MotionModel.h:123
DtTaitBryan rotationalVelocity
Definition: DtRk4MotionModel.h:214
double droll
Definition: DtRk4MotionModel.h:229
Base class to provide boost signal/slot management.
First and second derivatives of the simulation&#39;s motion state.
Definition: DtRk4MotionModel.h:218
double a_pitch
Definition: DtRk4MotionModel.h:241
void setRotationalInertia(double pitchInertia, double rollInertia)
Set roll and pitch inertia coefficients in entity local coordinates.
double myPitchTorque
Definition: DtRk4MotionModel.h:258
DtDe & myDe
Definition: DtRk4MotionModel.h:136
Helper class to draw a styleable line segment; generates a geode containing the line segment geometry...
Definition: Dt3DLineModelInstanceSegment.h:24
Derivative evaluate(const State &initial, double dt, const Derivative &d)
Compute the derivatives from the passed in motion state and initial derivatives, over time step dt...
DtDe & myDe
Definition: DtRk4MotionModel.h:269
void applyHeadingTorque(double magnitude)
Apply a torque around the up vector for the next frame.
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
double a_roll
Definition: DtRk4MotionModel.h:242
double myDensity
Density of the sample point in kg/m^3.
Definition: DtRk4MotionModel.h:126
voidpf uLong offset
Definition: ioapi.h:42
double computeForce(const DtVector &pos, const DtVector &vel, const DtDcm &ori)
Compute the net force along the object&#39;s up vector at the sample point.
double dv_roll
Definition: DtRk4MotionModel.h:230
Definition: DtRk4MotionModel.h:202
DtCoordinateConverter * myCoordinateConverter
Definition: DtRk4MotionModel.h:199
DtVector offset
Definition: DtRk4MotionModel.h:204
double a_y
Definition: DtRk4MotionModel.h:239
DtRk4MotionModel * myParent
Definition: DtRk4MotionModel.h:137
DtVector velocity() const
Get the object&#39;s linear velocity in world coordinates.
Second derivative of the simulation&#39;s motion state.
Definition: DtRk4MotionModel.h:236

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)