2007-03-20 20:54:52 +00:00
|
|
|
# geo functions
|
|
|
|
# -------------------------------------------------------------------------------------------------
|
|
|
|
# geo.Coord.new([<coord>]) ... class that holds and maintains geographical coordinates
|
|
|
|
# can be initialized with another geo.Coord instance
|
|
|
|
# Coord.set(<coord>) ... sets coordinates from another geo.Coord instance
|
|
|
|
#
|
2007-06-18 10:22:17 +00:00
|
|
|
# Coord.set_lat(<num>) ... functions for setting latitude/longitude/altitude
|
|
|
|
# Coord.set_lon(<num>)
|
2007-03-20 20:54:52 +00:00
|
|
|
# Coord.set_alt(<num>)
|
2007-06-18 10:22:17 +00:00
|
|
|
# Coord.set_latlon(<num>, <num> [, <num>]) (altitude is optional; default=0)
|
2007-03-20 20:54:52 +00:00
|
|
|
#
|
|
|
|
# Coord.set_x(<num>) ... functions for setting cartesian x/y/z coordinates
|
|
|
|
# Coord.set_y(<num>)
|
|
|
|
# Coord.set_z(<num>)
|
|
|
|
# Coord.set_xyz(<num>, <num>, <num>)
|
|
|
|
#
|
|
|
|
# Coord.lat()
|
2007-06-18 10:22:17 +00:00
|
|
|
# Coord.lon() ... functions for getting lat/lon/alt
|
2007-03-20 20:54:52 +00:00
|
|
|
# Coord.alt() ... returns altitude in m
|
2007-06-18 10:22:17 +00:00
|
|
|
# Coord.latlon() ... returns array [<lat>, <lon>, <alt>]
|
2007-03-20 20:54:52 +00:00
|
|
|
#
|
|
|
|
# Coord.x() ... functions for reading cartesian coords (in m)
|
|
|
|
# Coord.y()
|
|
|
|
# Coord.z()
|
|
|
|
# Coord.xyz() ... returns array [<x>, <y>, <z>]
|
|
|
|
#
|
|
|
|
# Coord.course_to(<coord>) ... returns course to another geo.Coord instance (degree)
|
|
|
|
# Coord.distance_to(<coord>) ... returns distance in m along Earth curvature, ignoring altitudes
|
|
|
|
# useful for map distance
|
|
|
|
# Coord.direct_distance_to(<coord>) ... distance in m direct, considers altitude,
|
2007-05-05 10:09:13 +00:00
|
|
|
# but cuts through Earth surface
|
2007-03-20 20:54:52 +00:00
|
|
|
#
|
|
|
|
# Coord.apply_course_distance(<course>, <distance>) ... guess what
|
|
|
|
# Coord.dump() ... outputs coordinates
|
|
|
|
# Coord.is_defined() ... returns whether the coords are defined
|
|
|
|
#
|
|
|
|
# geo.aircraft_position() ... returns current aircraft position as geo.Coord
|
|
|
|
# geo.click_position() ... returns last click coords as geo.Coord or nil before first click
|
|
|
|
#
|
2007-06-18 10:22:17 +00:00
|
|
|
# geo.tile_path(<lat>, <lon>) ... returns tile path string (e.g. "w130n30/w123n37/942056.stg")
|
|
|
|
# geo.elevation(<lat>, <lon>) ... returns elevation in meter for given lat/lon, or nil on error
|
2007-03-20 20:54:52 +00:00
|
|
|
# geo.normdeg(<angle>) ... returns angle normalized to 0 <= angle < 360
|
2007-05-31 20:19:26 +00:00
|
|
|
#
|
2007-06-18 10:22:17 +00:00
|
|
|
# geo.put_model(<path>, <lat>, <lon> [, <elev:nil> [, <hdg:0> [, <pitch:0> [, <roll:0>]]]]);
|
|
|
|
# ... put model <path> at location <lat>/<lon> with given elevation
|
2007-05-31 20:19:26 +00:00
|
|
|
# (optional, default: surface). <hdg>/<pitch>/<roll> are optional
|
|
|
|
# and default to zero.
|
2007-06-18 11:06:10 +00:00
|
|
|
# geo.put_model(<path>, <coord> [, <hdg:0> [, <pitch:0> [, <roll:0>]]]);
|
|
|
|
# ... same as above, but lat/lon/elev are taken from a Coord object
|
2007-03-20 20:54:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
var EPSILON = 0.0000000000001;
|
|
|
|
var ERAD = 6378138.12; # Earth radius (m)
|
|
|
|
var D2R = math.pi / 180;
|
|
|
|
var R2D = 180 / math.pi;
|
|
|
|
var FT2M = 0.3048;
|
|
|
|
var M2FT = 3.28083989501312335958;
|
|
|
|
|
|
|
|
|
2007-05-03 22:09:34 +00:00
|
|
|
var printf = func { print(call(sprintf, arg)) }
|
2007-03-20 20:54:52 +00:00
|
|
|
var floor = func(v) { v < 0.0 ? -int(-v) - 1 : int(v) }
|
2007-06-18 15:15:16 +00:00
|
|
|
var sin = nil;
|
|
|
|
var cos = nil;
|
|
|
|
var atan2 = nil;
|
|
|
|
var sqrt = nil;
|
|
|
|
var asin = nil;
|
|
|
|
var acos = nil;
|
|
|
|
var mod = nil;
|
2007-03-20 20:54:52 +00:00
|
|
|
|
|
|
|
|
2007-06-18 10:22:17 +00:00
|
|
|
# class that maintains one set of geographical coordinates
|
2007-03-20 20:54:52 +00:00
|
|
|
#
|
|
|
|
var Coord = {
|
|
|
|
new : func(copy = nil) {
|
|
|
|
var m = { parents: [Coord] };
|
|
|
|
m._pdirty = 1; # polar
|
|
|
|
m._cdirty = 1; # cartesian
|
2007-06-18 10:22:17 +00:00
|
|
|
m._lat = nil; # in radian
|
|
|
|
m._lon = nil; #
|
2007-03-20 20:54:52 +00:00
|
|
|
m._alt = nil; # ASL
|
|
|
|
m._x = nil; # in m
|
|
|
|
m._y = nil;
|
|
|
|
m._z = nil;
|
2007-06-18 10:33:37 +00:00
|
|
|
if (copy != nil)
|
2007-03-20 20:54:52 +00:00
|
|
|
m.set(copy);
|
2007-06-18 10:33:37 +00:00
|
|
|
|
2007-03-20 20:54:52 +00:00
|
|
|
return m;
|
|
|
|
},
|
|
|
|
_cupdate : func {
|
|
|
|
me._cdirty or return;
|
2007-06-16 18:26:06 +00:00
|
|
|
var xyz = geodtocart(me._lat * R2D, me._lon * R2D, me._alt);
|
|
|
|
me._x = xyz[0];
|
|
|
|
me._y = xyz[1];
|
|
|
|
me._z = xyz[2];
|
2007-03-20 20:54:52 +00:00
|
|
|
me._cdirty = 0;
|
|
|
|
},
|
|
|
|
_pupdate : func {
|
|
|
|
me._pdirty or return;
|
2007-06-16 18:26:06 +00:00
|
|
|
var lla = carttogeod(me._x, me._y, me._z);
|
|
|
|
me._lat = lla[0] * D2R;
|
|
|
|
me._lon = lla[1] * D2R;
|
|
|
|
me._alt = lla[2];
|
2007-03-20 20:54:52 +00:00
|
|
|
me._pdirty = 0;
|
|
|
|
},
|
|
|
|
|
|
|
|
x : func { me._cupdate(); me._x },
|
|
|
|
y : func { me._cupdate(); me._y },
|
|
|
|
z : func { me._cupdate(); me._z },
|
|
|
|
xyz : func { me._cupdate(); [me._x, me._y, me._z] },
|
|
|
|
|
2007-06-18 10:22:17 +00:00
|
|
|
lat : func { me._pupdate(); me._lat * R2D }, # return in degree
|
|
|
|
lon : func { me._pupdate(); me._lon * R2D },
|
2007-03-20 20:54:52 +00:00
|
|
|
alt : func { me._pupdate(); me._alt },
|
2007-06-18 11:06:10 +00:00
|
|
|
latlon : func { me._pupdate(); [me._lat * R2D, me._lon * R2D, me._alt] },
|
2007-03-20 20:54:52 +00:00
|
|
|
|
|
|
|
set_x : func(x) { me._pupdate(); me._pdirty = 1; me._x = x; me },
|
|
|
|
set_y : func(y) { me._pupdate(); me._pdirty = 1; me._y = y; me },
|
|
|
|
set_z : func(z) { me._pupdate(); me._pdirty = 1; me._z = z; me },
|
|
|
|
|
|
|
|
set_lat : func(lat) { me._cupdate(); me._cdirty = 1; me._lat = lat * D2R; me },
|
2007-06-18 10:22:17 +00:00
|
|
|
set_lon : func(lon) { me._cupdate(); me._cdirty = 1; me._lon = lon * D2R; me },
|
2007-03-20 20:54:52 +00:00
|
|
|
set_alt : func(alt) { me._cupdate(); me._cdirty = 1; me._alt = alt; me },
|
|
|
|
|
|
|
|
set : func(c) {
|
|
|
|
c._pupdate();
|
|
|
|
me._lat = c._lat;
|
2007-06-18 10:22:17 +00:00
|
|
|
me._lon = c._lon;
|
2007-03-20 20:54:52 +00:00
|
|
|
me._alt = c._alt;
|
|
|
|
me._cdirty = 1;
|
|
|
|
me._pdirty = 0;
|
|
|
|
me;
|
|
|
|
},
|
2007-06-18 10:22:17 +00:00
|
|
|
set_latlon : func(lat, lon, alt = 0) {
|
2007-03-20 20:54:52 +00:00
|
|
|
me._lat = lat * D2R;
|
2007-06-18 10:22:17 +00:00
|
|
|
me._lon = lon * D2R;
|
2007-03-20 20:54:52 +00:00
|
|
|
me._alt = alt;
|
|
|
|
me._cdirty = 1;
|
|
|
|
me._pdirty = 0;
|
|
|
|
me;
|
|
|
|
},
|
|
|
|
set_xyz : func(x, y, z) {
|
|
|
|
me._x = x;
|
|
|
|
me._y = y;
|
|
|
|
me._z = z;
|
|
|
|
me._pdirty = 1;
|
|
|
|
me._cdirty = 0;
|
|
|
|
me;
|
|
|
|
},
|
|
|
|
apply_course_distance : func(course, dist) {
|
|
|
|
me._pupdate();
|
|
|
|
course *= D2R;
|
|
|
|
dist /= ERAD;
|
|
|
|
me._lat = asin(sin(me._lat) * cos(dist) + cos(me._lat) * sin(dist) * cos(course));
|
|
|
|
|
2007-06-18 10:33:37 +00:00
|
|
|
if (cos(me._lat) > EPSILON)
|
2007-03-20 20:54:52 +00:00
|
|
|
me._lon = math.pi - mod(math.pi - me._lon - asin(sin(course) * sin(dist)
|
|
|
|
/ cos(me._lat)), 2 * math.pi);
|
2007-06-18 10:33:37 +00:00
|
|
|
|
2007-03-20 20:54:52 +00:00
|
|
|
me._cdirty = 1;
|
|
|
|
me;
|
|
|
|
},
|
|
|
|
course_to : func(dest) {
|
|
|
|
me._pupdate();
|
|
|
|
dest._pupdate();
|
|
|
|
|
2007-06-18 10:33:37 +00:00
|
|
|
if (me._lat == dest._lat and me._lon == dest._lon)
|
2007-03-20 20:54:52 +00:00
|
|
|
return 0;
|
2007-06-18 10:33:37 +00:00
|
|
|
|
2007-03-20 20:54:52 +00:00
|
|
|
var dlon = dest._lon - me._lon;
|
|
|
|
return mod(atan2(sin(dlon) * cos(dest._lat), cos(me._lat) * sin(dest._lat)
|
|
|
|
- sin(me._lat) * cos(dest._lat) * cos(dlon)), 2 * math.pi) * R2D;
|
|
|
|
},
|
|
|
|
# arc distance on an earth sphere; doesn't consider altitude
|
|
|
|
distance_to : func(dest) {
|
|
|
|
me._pupdate();
|
|
|
|
dest._pupdate();
|
|
|
|
|
2007-06-18 10:33:37 +00:00
|
|
|
if (me._lat == dest._lat and me._lon == dest._lon)
|
2007-03-20 20:54:52 +00:00
|
|
|
return 0;
|
2007-06-18 10:33:37 +00:00
|
|
|
|
2007-03-20 20:54:52 +00:00
|
|
|
var a = sin((me._lat - dest._lat) * 0.5);
|
2007-06-18 10:22:17 +00:00
|
|
|
var o = sin((me._lon - dest._lon) * 0.5);
|
2007-03-20 20:54:52 +00:00
|
|
|
return 2.0 * ERAD * asin(sqrt(a * a + cos(me._lat) * cos(dest._lat) * o * o));
|
|
|
|
},
|
|
|
|
direct_distance_to : func(dest) {
|
|
|
|
me._cupdate();
|
|
|
|
dest._cupdate();
|
|
|
|
var dx = dest._x - me._x;
|
|
|
|
var dy = dest._y - me._y;
|
|
|
|
var dz = dest._z - me._z;
|
|
|
|
return sqrt(dx * dx + dy * dy + dz * dz);
|
|
|
|
},
|
|
|
|
is_defined : func {
|
|
|
|
return !(me._cdirty and me._pdirty);
|
|
|
|
},
|
|
|
|
dump : func {
|
2007-06-18 10:33:37 +00:00
|
|
|
if (me._cdirty and me._pdirty)
|
2007-03-20 20:54:52 +00:00
|
|
|
print("Coord.print(): coord undefined");
|
2007-06-18 10:33:37 +00:00
|
|
|
|
2007-03-20 20:54:52 +00:00
|
|
|
me._cupdate();
|
|
|
|
me._pupdate();
|
2007-06-18 10:22:17 +00:00
|
|
|
printf("x=%f y=%f z=%f lat=%f lon=%f alt=%f",
|
|
|
|
me.x(), me.y(), me.z(), me.lat(), me.lon(), me.alt());
|
2007-03-20 20:54:52 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
# normalize degree to 0 <= angle < 360
|
|
|
|
#
|
|
|
|
var normdeg = func(angle) {
|
2007-06-18 10:33:37 +00:00
|
|
|
while (angle < 0)
|
2007-03-20 20:54:52 +00:00
|
|
|
angle += 360;
|
2007-06-18 10:33:37 +00:00
|
|
|
while (angle >= 360)
|
2007-03-20 20:54:52 +00:00
|
|
|
angle -= 360;
|
|
|
|
return angle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var bucket_span = func(lat) {
|
2007-06-18 10:33:37 +00:00
|
|
|
if (lat >= 89.0)
|
2007-03-20 20:54:52 +00:00
|
|
|
360.0;
|
2007-06-18 10:33:37 +00:00
|
|
|
elsif (lat >= 88.0)
|
2007-03-20 20:54:52 +00:00
|
|
|
8.0;
|
2007-06-18 10:33:37 +00:00
|
|
|
elsif (lat >= 86.0)
|
2007-03-20 20:54:52 +00:00
|
|
|
4.0;
|
2007-06-18 10:33:37 +00:00
|
|
|
elsif (lat >= 83.0)
|
2007-03-20 20:54:52 +00:00
|
|
|
2.0;
|
2007-06-18 10:33:37 +00:00
|
|
|
elsif (lat >= 76.0)
|
2007-03-20 20:54:52 +00:00
|
|
|
1.0;
|
2007-06-18 10:33:37 +00:00
|
|
|
elsif (lat >= 62.0)
|
2007-03-20 20:54:52 +00:00
|
|
|
0.5;
|
2007-06-18 10:33:37 +00:00
|
|
|
elsif (lat >= 22.0)
|
2007-03-20 20:54:52 +00:00
|
|
|
0.25;
|
2007-06-18 10:33:37 +00:00
|
|
|
elsif (lat >= -22.0)
|
2007-03-20 20:54:52 +00:00
|
|
|
0.125;
|
2007-06-18 10:33:37 +00:00
|
|
|
elsif (lat >= -62.0)
|
2007-03-20 20:54:52 +00:00
|
|
|
0.25;
|
2007-06-18 10:33:37 +00:00
|
|
|
elsif (lat >= -76.0)
|
2007-03-20 20:54:52 +00:00
|
|
|
0.5;
|
2007-06-18 10:33:37 +00:00
|
|
|
elsif (lat >= -83.0)
|
2007-03-20 20:54:52 +00:00
|
|
|
1.0;
|
2007-06-18 10:33:37 +00:00
|
|
|
elsif (lat >= -86.0)
|
2007-03-20 20:54:52 +00:00
|
|
|
2.0;
|
2007-06-18 10:33:37 +00:00
|
|
|
elsif (lat >= -88.0)
|
2007-03-20 20:54:52 +00:00
|
|
|
4.0;
|
2007-06-18 10:33:37 +00:00
|
|
|
elsif (lat >= -89.0)
|
2007-03-20 20:54:52 +00:00
|
|
|
8.0;
|
2007-06-18 10:33:37 +00:00
|
|
|
else
|
2007-03-20 20:54:52 +00:00
|
|
|
360.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-18 10:22:17 +00:00
|
|
|
var tile_index = func(lat, lon) {
|
2007-03-20 20:54:52 +00:00
|
|
|
var lat_floor = floor(lat);
|
2007-06-18 10:22:17 +00:00
|
|
|
var lon_floor = floor(lon);
|
2007-03-20 20:54:52 +00:00
|
|
|
var span = bucket_span(lat);
|
|
|
|
var x = 0;
|
|
|
|
|
|
|
|
if (span < 0.0000001) {
|
|
|
|
lon = 0;
|
|
|
|
} elsif (span <= 1.0) {
|
|
|
|
x = int((lon - lon_floor) / span);
|
|
|
|
} else {
|
|
|
|
if (lon >= 0) {
|
|
|
|
lon = int(int(lon / span) * span);
|
|
|
|
} else {
|
|
|
|
lon = int(int((lon + 1) / span) * span - span);
|
2007-06-18 10:33:37 +00:00
|
|
|
if (lon < -180)
|
2007-03-20 20:54:52 +00:00
|
|
|
lon = -180;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var y = int((lat - lat_floor) * 8);
|
2007-06-18 10:22:17 +00:00
|
|
|
return (lon_floor + 180) * 16384 + (lat_floor + 90) * 64 + y * 8 + x;
|
2007-03-20 20:54:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-18 10:22:17 +00:00
|
|
|
var format = func(lat, lon) {
|
2007-03-20 20:54:52 +00:00
|
|
|
sprintf("%s%03d%s%02d", lon < 0 ? "w" : "e", abs(lon), lat < 0 ? "s" : "n", abs(lat));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-18 10:22:17 +00:00
|
|
|
var tile_path = func(lat, lon) {
|
|
|
|
var p = format(floor(lat / 10.0) * 10, floor(lon / 10.0) * 10);
|
|
|
|
p ~= "/" ~ format(floor(lat), floor(lon));
|
|
|
|
p ~= "/" ~ tile_index(lat, lon) ~ ".stg";
|
2007-03-20 20:54:52 +00:00
|
|
|
}
|
|
|
|
|
2007-06-18 11:06:10 +00:00
|
|
|
var put_model = func(path, c, arg...) {
|
|
|
|
call(_put_model, [path] ~ (isa(c, Coord) ? c.latlon() : [c]) ~ arg);
|
|
|
|
}
|
2007-03-20 20:54:52 +00:00
|
|
|
|
2007-06-18 11:06:10 +00:00
|
|
|
var _put_model = func(path, lat, lon, elev_m = nil, hdg = 0, pitch = 0, roll = 0) {
|
2007-05-12 18:38:57 +00:00
|
|
|
if (elev_m == nil)
|
2007-06-18 10:22:17 +00:00
|
|
|
elev_m = elevation(lat, lon);
|
2007-05-12 18:38:57 +00:00
|
|
|
if (elev_m == nil)
|
2007-06-18 10:22:17 +00:00
|
|
|
die("can't get elevation for " ~ lat ~ "/" ~ lon);
|
2007-05-12 18:38:57 +00:00
|
|
|
var n = props.globals.getNode("/models");
|
|
|
|
for (var i = 0; 1; i += 1)
|
|
|
|
if (n.getChild("model", i, 0) == nil)
|
|
|
|
break;
|
|
|
|
n = n.getChild("model", i, 1);
|
|
|
|
n.getNode("path", 1).setValue(path);
|
|
|
|
n.getNode("latitude-deg", 1).setDoubleValue(lat);
|
2007-06-18 10:22:17 +00:00
|
|
|
n.getNode("longitude-deg", 1).setDoubleValue(lon);
|
2007-05-15 20:46:59 +00:00
|
|
|
n.getNode("elevation-ft", 1).setDoubleValue(elev_m * M2FT);
|
2007-05-12 18:38:57 +00:00
|
|
|
n.getNode("heading-deg", 1).setDoubleValue(hdg);
|
|
|
|
n.getNode("pitch-deg", 1).setDoubleValue(pitch);
|
|
|
|
n.getNode("roll-deg", 1).setDoubleValue(roll);
|
|
|
|
n.getNode("load", 1).setBoolValue(1);
|
|
|
|
n.removeChildren("load");
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-05-05 10:09:13 +00:00
|
|
|
var terr_tree = nil;
|
|
|
|
var terr_lon = nil;
|
|
|
|
var terr_lat = nil;
|
|
|
|
var terr_elev = nil;
|
|
|
|
|
2007-06-18 10:22:17 +00:00
|
|
|
var elevation = func(lat, lon) {
|
2007-05-05 10:09:13 +00:00
|
|
|
terr_lat.setDoubleValue(lat);
|
2007-06-18 10:22:17 +00:00
|
|
|
terr_lon.setDoubleValue(lon);
|
2007-05-05 10:09:13 +00:00
|
|
|
var success = fgcommand("terrain-elevation", terr_tree);
|
|
|
|
return success ? terr_elev.getValue() : nil;
|
2007-05-03 22:09:34 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 20:54:52 +00:00
|
|
|
|
|
|
|
var aircraft_lat = nil;
|
2007-06-18 10:22:17 +00:00
|
|
|
var aircraft_lon = nil;
|
2007-03-20 20:54:52 +00:00
|
|
|
var aircraft_alt = nil;
|
|
|
|
|
|
|
|
var aircraft_position = func {
|
|
|
|
var lat = aircraft_lat.getValue();
|
2007-06-18 10:22:17 +00:00
|
|
|
var lon = aircraft_lon.getValue();
|
2007-03-20 20:54:52 +00:00
|
|
|
var alt = aircraft_alt.getValue() * FT2M;
|
2007-06-18 10:22:17 +00:00
|
|
|
return Coord.new().set_latlon(lat, lon, alt);
|
2007-03-20 20:54:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var click_lat = nil;
|
2007-06-18 10:22:17 +00:00
|
|
|
var click_lon = nil;
|
2007-03-20 20:54:52 +00:00
|
|
|
var click_elev = nil;
|
|
|
|
var click_coord = Coord.new();
|
|
|
|
|
|
|
|
_setlistener("/sim/signals/click", func {
|
|
|
|
var lat = click_lat.getValue();
|
2007-06-18 10:22:17 +00:00
|
|
|
var lon = click_lon.getValue();
|
2007-03-20 20:54:52 +00:00
|
|
|
var elev = click_elev.getValue();
|
2007-06-18 10:22:17 +00:00
|
|
|
click_coord.set_latlon(lat, lon, elev);
|
2007-03-20 20:54:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var click_position = func {
|
2007-05-12 18:38:57 +00:00
|
|
|
return click_coord.is_defined() ? Coord.new(click_coord) : nil;
|
2007-03-20 20:54:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_setlistener("/sim/signals/nasal-dir-initialized", func {
|
2007-06-18 15:15:16 +00:00
|
|
|
sin = math.sin;
|
|
|
|
cos = math.cos;
|
|
|
|
atan2 = math.atan2;
|
|
|
|
sqrt = math.sqrt;
|
|
|
|
asin = math.asin;
|
|
|
|
acos = math.acos;
|
|
|
|
mod = math.mod;
|
|
|
|
|
2007-05-05 10:09:13 +00:00
|
|
|
terr_tree = props.Node.new();
|
|
|
|
terr_lat = terr_tree.getNode("latitude-deg", 1);
|
2007-06-18 10:22:17 +00:00
|
|
|
terr_lon = terr_tree.getNode("longitude-deg", 1);
|
2007-05-05 10:09:13 +00:00
|
|
|
terr_elev = terr_tree.getNode("elevation-m", 1);
|
2007-05-15 20:46:59 +00:00
|
|
|
|
2007-05-05 10:09:13 +00:00
|
|
|
terr_lat.setDoubleValue(0.0);
|
2007-06-18 10:22:17 +00:00
|
|
|
terr_lon.setDoubleValue(0.0);
|
2007-05-15 20:46:59 +00:00
|
|
|
terr_elev.setDoubleValue(-9999.0);
|
2007-05-05 10:09:13 +00:00
|
|
|
|
2007-03-20 20:54:52 +00:00
|
|
|
aircraft_lat = props.globals.getNode("/position/latitude-deg", 1);
|
2007-06-18 10:22:17 +00:00
|
|
|
aircraft_lon = props.globals.getNode("/position/longitude-deg", 1);
|
2007-03-20 20:54:52 +00:00
|
|
|
aircraft_alt = props.globals.getNode("/position/altitude-ft", 1);
|
|
|
|
|
|
|
|
click_lat = props.globals.getNode("/sim/input/click/latitude-deg", 1);
|
2007-06-18 10:22:17 +00:00
|
|
|
click_lon = props.globals.getNode("/sim/input/click/longitude-deg", 1);
|
2007-03-20 20:54:52 +00:00
|
|
|
click_elev = props.globals.getNode("/sim/input/click/elevation-m", 1);
|
|
|
|
});
|
2007-05-05 10:09:13 +00:00
|
|
|
|