- waypoint *wpt;
-
- // Get the current active runway, based on code from David Luff
- // This should actually be unified and extended to include
- // Preferential runway use schema's
- if (firstFlight)
- {
- string rwyClass = getRunwayClassFromTrafficType(fltType);
- apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway);
- rwy = apt->getRunwayByIdent(activeRunway);
- }
-
- double airportElev = apt->getElevation();
- // Acceleration point, 105 meters into the runway,
- SGGeod accelPoint = rwy->pointOnCenterline(105.0);
- wpt = createOnGround("accel", accelPoint, airportElev, speed);
- waypoints.push_back(wpt);
-
- //Start Climbing to 3000 ft. Let's do this
- // at the center of the runway for now:
- wpt = cloneWithPos(wpt, "SOC", rwy->geod());
- wpt->altitude = airportElev+1000;
- wpt->on_ground = false;
- waypoints.push_back(wpt);
-
- wpt = cloneWithPos(wpt, "3000 ft", rwy->end());
- wpt->altitude = airportElev+3000;
- waypoints.push_back(wpt);
-
-// Finally, add two more waypoints, so that aircraft will remain under
- // Tower control until they have reached the 3000 ft climb point
- SGGeod pt = rwy->pointOnCenterline(5000 + rwy->lengthM() * 0.5);
- wpt = cloneWithPos(wpt, "5000 ft", pt);
- wpt->altitude = airportElev+5000;
- waypoints.push_back(wpt);
+ double accel = ac->getPerformance()->acceleration();
+ double vTaxi = ac->getPerformance()->vTaxi();
+ double vRotate = ac->getPerformance()->vRotate();
+// double vTakeoff = ac->getPerformance()->vTakeoff();
+ double vClimb = ac->getPerformance()->vClimb();
+ // Acceleration = dV / dT
+ // Acceleration X dT = dV
+ // dT = dT / Acceleration
+ //d = (Vf^2 - Vo^2) / (2*a)
+// double accelTime = (vRotate - vTaxi) / accel;
+ //cerr << "Using " << accelTime << " as total acceleration time" << endl;
+ double accelDistance = (vRotate*vRotate - vTaxi*vTaxi) / (2*accel);
+ //cerr << "Using " << accelDistance << " " << accel << " " << vRotate << endl;
+ waypoint *wpt;
+ // Get the current active runway, based on code from David Luff
+ // This should actually be unified and extended to include
+ // Preferential runway use schema's
+ // NOTE: DT (2009-01-18: IIRC, this is currently already the case,
+ // because the getActive runway function takes care of that.
+ if (firstFlight)
+ {
+ string rwyClass = getRunwayClassFromTrafficType(fltType);
+ double heading = ac->getTrafficRef()->getCourse();
+ apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway, heading);
+ rwy = apt->getRunwayByIdent(activeRunway);
+ }
+
+ double airportElev = apt->getElevation();
+ // Acceleration point, 105 meters into the runway,
+ SGGeod accelPoint = rwy->pointOnCenterline(105.0);
+ wpt = createOnGround(ac, "accel", accelPoint, airportElev, vClimb);
+ waypoints.push_back(wpt);
+
+ //Start Climbing to 3000 ft. Let's do this
+ // at the center of the runway for now:
+ SGGeod rotate = rwy->pointOnCenterline(105.0+accelDistance);
+ wpt = cloneWithPos(ac, wpt, "SOC", rotate);
+ wpt->altitude = airportElev+1000;
+ wpt->on_ground = false;
+ waypoints.push_back(wpt);
+
+ wpt = cloneWithPos(ac, wpt, "3000 ft", rwy->end());
+ wpt->altitude = airportElev+3000;
+ waypoints.push_back(wpt);
+
+ // Finally, add two more waypoints, so that aircraft will remain under
+ // Tower control until they have reached the 3000 ft climb point
+ SGGeod pt = rwy->pointOnCenterline(5000 + rwy->lengthM() * 0.5);
+ wpt = cloneWithPos(ac, wpt, "5000 ft", pt);
+ wpt->altitude = airportElev+5000;
+ waypoints.push_back(wpt);