Vivian Meazza:
I had to reverse a number of signs to get it right. I took the opportunity to add roll to the submodel so that droptanks will come off with the right orientation. I have neither added the rotational speed to the submodel, nor yaw, so if you release droptanks with significant roll rate or yaw angle on the aircraft the submodel will not be quite right. Straight and level, or nearly so, is fine.
This commit is contained in:
parent
cc3d0221ea
commit
6d76e9da80
5 changed files with 26 additions and 16 deletions
|
@ -35,6 +35,7 @@ FGAIBallistic::FGAIBallistic(FGAIManager* mgr) {
|
|||
life_timer = 0.0;
|
||||
gravity = 32;
|
||||
// buoyancy = 64;
|
||||
no_roll = false;
|
||||
}
|
||||
|
||||
FGAIBallistic::~FGAIBallistic() {
|
||||
|
@ -46,6 +47,7 @@ bool FGAIBallistic::init() {
|
|||
aero_stabilized = true;
|
||||
hdg = azimuth;
|
||||
pitch = elevation;
|
||||
roll = rotation;
|
||||
Transform();
|
||||
return true;
|
||||
}
|
||||
|
@ -78,6 +80,9 @@ void FGAIBallistic::setElevation(double el) {
|
|||
pitch = elevation = el;
|
||||
}
|
||||
|
||||
void FGAIBallistic::setRoll(double rl) {
|
||||
rotation = rl;
|
||||
}
|
||||
|
||||
void FGAIBallistic::setStabilization(bool val) {
|
||||
aero_stabilized = val;
|
||||
|
@ -171,3 +176,4 @@ double FGAIBallistic::_getTime() const {
|
|||
return life_timer;
|
||||
}
|
||||
|
||||
// end AIBallistic
|
|
@ -38,6 +38,7 @@ public:
|
|||
|
||||
void setAzimuth( double az );
|
||||
void setElevation( double el );
|
||||
void setRoll( double rl );
|
||||
void setStabilization( bool val );
|
||||
void setDragArea( double a );
|
||||
void setLife( double seconds );
|
||||
|
@ -52,6 +53,7 @@ private:
|
|||
|
||||
double azimuth; // degrees true
|
||||
double elevation; // degrees
|
||||
double rotation; // degrees
|
||||
double hs; // horizontal speed (fps)
|
||||
bool aero_stabilized; // if true, object will point where it's going
|
||||
double drag_area; // equivalent drag area in ft2
|
||||
|
|
|
@ -202,6 +202,7 @@ FGAIManager::createBallistic( FGAIModelEntity *entity ) {
|
|||
ai_ballistic->setWind_from_east(entity->wind_from_east);
|
||||
ai_ballistic->setWind_from_north(entity->wind_from_north);
|
||||
ai_ballistic->setWind(entity->wind);
|
||||
ai_ballistic->setRoll(entity->roll);
|
||||
ai_ballistic->init();
|
||||
ai_ballistic->bind();
|
||||
return ai_ballistic;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
// submodel.cxx - models a releasable submodel.
|
||||
// Written by Dave Culp, started Aug 2004
|
||||
//
|
||||
|
@ -117,6 +116,7 @@ SubmodelSystem::release (submodel* sm, double dt)
|
|||
entity.altitude = IC.alt;
|
||||
entity.azimuth = IC.azimuth;
|
||||
entity.elevation = IC.elevation;
|
||||
entity.roll = IC.roll;
|
||||
entity.speed = IC.speed;
|
||||
entity.eda = sm->drag_area;
|
||||
entity.life = sm->life;
|
||||
|
@ -200,8 +200,8 @@ SubmodelSystem::transform( submodel* sm)
|
|||
IC.lat = _user_lat_node->getDoubleValue();
|
||||
IC.lon = _user_lon_node->getDoubleValue();
|
||||
IC.alt = _user_alt_node->getDoubleValue();
|
||||
IC.roll = - _user_roll_node->getDoubleValue(); // rotation about x axis (-ve)
|
||||
IC.elevation = - _user_pitch_node->getDoubleValue(); // rotation about y axis (-ve)
|
||||
IC.roll = _user_roll_node->getDoubleValue(); // rotation about x axis
|
||||
IC.elevation = _user_pitch_node->getDoubleValue(); // rotation about y axis
|
||||
IC.azimuth = _user_heading_node->getDoubleValue(); // rotation about z axis
|
||||
|
||||
IC.speed = _user_speed_node->getDoubleValue();
|
||||
|
@ -219,10 +219,10 @@ SubmodelSystem::transform( submodel* sm)
|
|||
|
||||
// pre-process the trig functions
|
||||
|
||||
cosRx = cos(IC.roll * SG_DEGREES_TO_RADIANS);
|
||||
sinRx = sin(IC.roll * SG_DEGREES_TO_RADIANS);
|
||||
cosRy = cos(IC.elevation * SG_DEGREES_TO_RADIANS);
|
||||
sinRy = sin(IC.elevation * SG_DEGREES_TO_RADIANS);
|
||||
cosRx = cos(-IC.roll * SG_DEGREES_TO_RADIANS);
|
||||
sinRx = sin(-IC.roll * SG_DEGREES_TO_RADIANS);
|
||||
cosRy = cos(-IC.elevation * SG_DEGREES_TO_RADIANS);
|
||||
sinRy = sin(-IC.elevation * SG_DEGREES_TO_RADIANS);
|
||||
cosRz = cos(IC.azimuth * SG_DEGREES_TO_RADIANS);
|
||||
sinRz = sin(IC.azimuth * SG_DEGREES_TO_RADIANS);
|
||||
|
||||
|
@ -265,7 +265,7 @@ SubmodelSystem::transform( submodel* sm)
|
|||
|
||||
// Get submodel initial velocity vector angles in XZ and XY planes.
|
||||
// This needs to be fixed. This vector should be added to aircraft's vector.
|
||||
IC.elevation += (sm->yaw_offset * sinRx) - (sm->pitch_offset * cosRx);
|
||||
IC.elevation += (sm->yaw_offset * sinRx) + (sm->pitch_offset * cosRx);
|
||||
IC.azimuth += (sm->yaw_offset * cosRx) - (sm->pitch_offset * sinRx);
|
||||
|
||||
// For now assume vector is close to airplane's vector. This needs to be fixed.
|
||||
|
@ -305,9 +305,8 @@ SubmodelSystem::transform( submodel* sm)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
IC.elevation = atan(IC.total_speed_down/sqrt(IC.total_speed_north * IC.total_speed_north +
|
||||
IC.elevation = -atan(IC.total_speed_down/sqrt(IC.total_speed_north *
|
||||
IC.total_speed_north +
|
||||
IC.total_speed_east * IC.total_speed_east)) * SG_RADIANS_TO_DEGREES;
|
||||
|
||||
}
|
||||
|
@ -323,3 +322,4 @@ SubmodelSystem::updatelat(double lat)
|
|||
// end of submodel.cxx
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -127,3 +127,4 @@ private:
|
|||
};
|
||||
|
||||
#endif // __SYSTEMS_SUBMODEL_HXX
|
||||
|
||||
|
|
Loading…
Reference in a new issue