1
0
Fork 0

Changed speed match function to use target distance instead of airspeed ... not perfected yet ,but better ...

This commit is contained in:
sydadams 2007-08-20 06:22:06 +00:00
parent 514f2c1ce7
commit a7f90a8cb8

View file

@ -8,7 +8,11 @@ var R2D = 180 / math.pi;
var sin = func(v) math.sin(v * D2R);
var cos = func(v) math.cos(v * D2R);
var atan2 = func(v, w) math.atan2(v, w) * R2D;
var time=0;
var lasttime=0;
var seconds =0;
var dist=0;
var lastdist=0;
var panel_dialog = gui.Dialog.new("/sim/gui/dialogs/cam/panel/dialog",
"Aircraft/ufo/Dialogs/cam.xml");
var callsign_dialog = gui.Dialog.new("/sim/gui/dialogs/cam/select/dialog",
@ -106,6 +110,7 @@ var update_aircraft_list = func {
var update = func {
# data acquisition
target.set_latlon(
targetN.getNode("position/latitude-deg").getValue(),
targetN.getNode("position/longitude-deg").getValue(),
@ -169,18 +174,25 @@ if (0) {
}
# calculate own speed
if (mode.speed.getValue())
maxspeed = targetN.getNode("velocities/true-airspeed-kt").getValue() * MPS * 2;
else
if (mode.speed.getValue()){
dist=targetN.getNode("radar/range-nm").getValue();
var nmps =dist-lastdist*seconds;
nmps =nmps*1852;
maxspeed = nmps * 2;
lastdist=dist;
}else{
maxspeed = speed[current];
}
maxspeedN.setDoubleValue(lowpass.speed.filter(maxspeed));
}
var loop = func {
time=getprop("/sim/time/elapsed-sec");
seconds=time-lasttime;
if (view_number == cam_view and targetN != nil)
update();
lasttime=time;
settimer(loop, 0);
}
@ -309,6 +321,7 @@ setlistener("/sim/signals/fdm-initialized", func {
setprop("/sim/current-view/view-number", cam_view);
setprop("/engines/engine/speed-max-mps", 500);
update_aircraft();
lasttime=getprop("/sim/time/elapsed-sec");
loop();
});