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);
|
_vBodyNode->setValue(ecLinearVel[1] * SG_METER_TO_FEET);
|
||||||
_wBodyNode->setValue(ecLinearVel[2] * 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) {
|
if (ecLinearVel[0] == 0) {
|
||||||
// MP packets for carriers have zero ecLinearVel, but do specify
|
// MP packets for carriers have zero ecLinearVel, but do specify
|
||||||
// velocities/speed-kts.
|
// velocities/speed-kts.
|
||||||
double speed_kts = props->getDoubleValue("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);
|
_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
|
// doesn't slip when carrier changes course. Also would be good to
|
||||||
// handle vbody and wbody?]
|
// 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"));
|
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
|
// Compute the velocity in m/s in the body frame
|
||||||
// <speed> is in knots.
|
// <speed> is in knots.
|
||||||
double knots2si = 1852.0/3600;
|
aip.setBodyLinearVelocity(SGVec3d(speed * SG_KT_TO_MPS, 0, 0));
|
||||||
aip.setBodyLinearVelocity(SGVec3d(speed * knots2si, 0, 0));
|
|
||||||
|
|
||||||
// Update speed_fps so that velocities/uBody-fps will be set. <speed>
|
// Update speed_fps so that velocities/uBody-fps will be set. <speed>
|
||||||
// is in knots.
|
// is in knots.
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
double knots2si = 1852.0/3600; // Knots to metres/sec.
|
speed_fps = speed * SG_KT_TO_FPS;
|
||||||
double ft2si = 12 * 2.54 / 100; // Feet to metres
|
|
||||||
speed_fps = speed * knots2si / ft2si;
|
|
||||||
}
|
}
|
||||||
FGAIBase::update(dt);
|
FGAIBase::update(dt);
|
||||||
Run(dt);
|
Run(dt);
|
||||||
|
@ -331,9 +328,7 @@ void FGAIShip::Run(double dt) {
|
||||||
z-back. */
|
z-back. */
|
||||||
SGQuatd q(-0.5, -0.5, 0.5, 0.5);
|
SGQuatd q(-0.5, -0.5, 0.5, 0.5);
|
||||||
|
|
||||||
double knots2si = 1852.0/3600;
|
SGVec3d offset(0, 0, -speed * SG_KT_TO_MPS * dt);
|
||||||
|
|
||||||
SGVec3d offset(0, 0, -speed * knots2si * dt);
|
|
||||||
position += (ec2body * q).backTransform(offset);
|
position += (ec2body * q).backTransform(offset);
|
||||||
pos = SGGeod::fromCart(position);
|
pos = SGGeod::fromCart(position);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue