[Gcblue-commits] gcb_wx/src/common simmath.cpp,1.11,1.12
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2004-07-19 00:53:11
|
Update of /cvsroot/gcblue/gcb_wx/src/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28653/src/common Modified Files: simmath.cpp Log Message: Index: simmath.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/simmath.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** simmath.cpp 8 May 2004 21:25:25 -0000 1.11 --- simmath.cpp 19 Jul 2004 00:53:00 -0000 1.12 *************** *** 422,425 **** --- 422,457 ---- return tclosest; } + + /** + * Calculates the ground impact point (lon_rad, lat_rad) + * assuming constant velocity motion to impact. + * This has not been tested. + * + * @param terrainHeight_m assumed terrain height in meters + * @param lon_rad longitude in radians of impact point + * @param lat_rad latitude in radians of impact point + * @return time of impact in seconds, negative indicates past + */ + float tcKinematics::CalculateGroundImpactPoint(float terrainHeight_m, + double& lon_rad, double& lat_rad) + { + + float dz = terrainHeight_m - mfAlt_m; + float v = C_KTSTOMPS*mfSpeed_kts; + float vz = v*sinf(mfPitch_rad); + + float timpact = dz / vz; + + float cospitch = cosf(mfPitch_rad); + float k = C_MTORAD * timpact * v * cospitch; + float dlon = k * sinf(mfHeading_rad) / cosf(mfLat_rad); + float dlat = k * cosf(mfHeading_rad); + + lon_rad = mfLon_rad + dlon; + lat_rad = mfLat_rad + dlat; + + return timpact; + } + // returns radian heading to track float tcKinematics::HeadingToTrack(const tcTrack& track) { |