src/AIModel/: use Simgear's unit conversion constants, e.g. SG_KT_TO_FPS.
This commit is contained in:
parent
df98d54948
commit
08390be391
2 changed files with 5 additions and 13 deletions
|
@ -713,14 +713,11 @@ void FGAIMultiplayer::update(double dt)
|
|||
_vBodyNode->setValue(ecLinearVel[1] * SG_METER_TO_FEET);
|
||||
_wBodyNode->setValue(ecLinearVel[2] * SG_METER_TO_FEET);
|
||||
|
||||
double knots2si = 1852.0/3600; // Knots to metres/sec.
|
||||
double ft2si = 12 * 2.54 / 100; // Feet to metres
|
||||
|
||||
if (ecLinearVel[0] == 0) {
|
||||
// MP packets for carriers have zero ecLinearVel, but do specify
|
||||
// velocities/speed-kts.
|
||||
double speed_kts = props->getDoubleValue("velocities/speed-kts");
|
||||
double speed_fps = speed_kts * knots2si / ft2si;
|
||||
double speed_fps = speed_kts * SG_KT_TO_FPS;
|
||||
_uBodyNode->setDoubleValue(speed_fps);
|
||||
}
|
||||
|
||||
|
@ -767,7 +764,7 @@ void FGAIMultiplayer::update(double dt)
|
|||
// doesn't slip when carrier changes course. Also would be good to
|
||||
// handle vbody and wbody?]
|
||||
//
|
||||
m_node_ai_latch_speed_kts->setDoubleValue(_uBodyNode->getDoubleValue() * ft2si / knots2si);
|
||||
m_node_ai_latch_speed_kts->setDoubleValue(_uBodyNode->getDoubleValue() * SG_FPS_TO_KT);
|
||||
}
|
||||
assert(m_node_ai_latch == props->getNode("ai-latch"));
|
||||
|
||||
|
|
|
@ -240,16 +240,13 @@ void FGAIShip::update(double dt) {
|
|||
|
||||
// Compute the velocity in m/s in the body frame
|
||||
// <speed> is in knots.
|
||||
double knots2si = 1852.0/3600;
|
||||
aip.setBodyLinearVelocity(SGVec3d(speed * knots2si, 0, 0));
|
||||
aip.setBodyLinearVelocity(SGVec3d(speed * SG_KT_TO_MPS, 0, 0));
|
||||
|
||||
// Update speed_fps so that velocities/uBody-fps will be set. <speed>
|
||||
// is in knots.
|
||||
//
|
||||
{
|
||||
double knots2si = 1852.0/3600; // Knots to metres/sec.
|
||||
double ft2si = 12 * 2.54 / 100; // Feet to metres
|
||||
speed_fps = speed * knots2si / ft2si;
|
||||
speed_fps = speed * SG_KT_TO_FPS;
|
||||
}
|
||||
FGAIBase::update(dt);
|
||||
Run(dt);
|
||||
|
@ -331,9 +328,7 @@ void FGAIShip::Run(double dt) {
|
|||
z-back. */
|
||||
SGQuatd q(-0.5, -0.5, 0.5, 0.5);
|
||||
|
||||
double knots2si = 1852.0/3600;
|
||||
|
||||
SGVec3d offset(0, 0, -speed * knots2si * dt);
|
||||
SGVec3d offset(0, 0, -speed * SG_KT_TO_MPS * dt);
|
||||
position += (ec2body * q).backTransform(offset);
|
||||
pos = SGGeod::fromCart(position);
|
||||
|
||||
|
|
Loading…
Reference in a new issue