[Gcblue-commits] gcb_wx/src/common simmath.cpp,1.4,1.5 tcSound.cpp,1.10,1.11
Status: Alpha
Brought to you by:
ddcforge
From: <ddc...@us...> - 2004-01-20 03:02:56
|
Update of /cvsroot/gcblue/gcb_wx/src/common In directory sc8-pr-cvs1:/tmp/cvs-serv12457/src/common Modified Files: simmath.cpp tcSound.cpp Log Message: Index: simmath.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/simmath.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** simmath.cpp 8 Jan 2004 23:54:27 -0000 1.4 --- simmath.cpp 20 Jan 2004 03:02:53 -0000 1.5 *************** *** 287,290 **** --- 287,325 ---- } /******************************* tcKinematics *******************************/ + + /** + * Calculates closest distance that collider comes to object represented + * by tcKinematics. + * @param dx x separation in meters in model coordinates + * @param dy y separation in meters in model coordinates + * @param dz z separation in meters in model coordinates + * @return time of closest distance in seconds, negative indicates past + */ + float tcKinematics::CalculateCollisionPoint(const tcKinematics& collider, float& dxi, float& dyi, float& dzi) + { + double dlon = mfLon_rad - collider.mfLon_rad; + double dlat = mfLat_rad - collider.mfLat_rad; + + float dx = C_RADTOM*cosf(mfLat_rad)*((float)dlon); + float dy = C_RADTOM*((float)dlat); + float dz = mfAlt_m - collider.mfAlt_m; + + float v = C_KTSTOMPS*mfSpeed_kts; + float vc = C_KTSTOMPS*mfSpeed_kts; + float dvz = v*sinf(mfPitch_rad) - vc*sinf(collider.mfPitch_rad); + float cospitch = cosf(mfPitch_rad); + float cospitchc = cosf(collider.mfPitch_rad); + float dvx = v*cospitch*sinf(mfHeading_rad) - vc*cospitchc*sinf(collider.mfHeading_rad); + float dvy = v*cospitch*cosf(mfHeading_rad) - vc*cospitchc*cosf(collider.mfHeading_rad); + + float tclosest = -(dx*dvx + dy*dvy + dz*dvz) / + (dvx*dvx + dvy*dvy + dvz*dvz); + + dxi = dx + dvx*tclosest; + dyi = dy + dvy*tclosest; + dzi = dz + dvz*tclosest; + + return tclosest; + } // returns radian heading to track float tcKinematics::HeadingToTrack(const tcTrack& track) { Index: tcSound.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/tcSound.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tcSound.cpp 1 Jan 2004 23:44:46 -0000 1.10 --- tcSound.cpp 20 Jan 2004 03:02:53 -0000 1.11 *************** *** 223,227 **** meMusicState = MS_WAIT; oggStreamer->Open(musicPath); ! oggStreamer->Display(); oggStreamer->Play(); oggStreamer->SetPause(false); --- 223,227 ---- meMusicState = MS_WAIT; oggStreamer->Open(musicPath); ! // oggStreamer->Display(); // uncomment to log ogg info to stdout oggStreamer->Play(); oggStreamer->SetPause(false); |