1
0
Fork 0

dynamic_view.nas: use D2R/R2D constants

globals.nas: move constants to top
geo.nas: fix comments & make bucket_span "private"
This commit is contained in:
mfranz 2008-11-20 20:18:39 +00:00
parent 6f6aef2fed
commit 55b7e3d8e0
3 changed files with 15 additions and 15 deletions

View file

@ -38,8 +38,8 @@ var FREEZE_DURATION = 2;
var BLEND_TIME = 0.2;
var sin = func(a) { math.sin(a * math.pi / 180.0) }
var cos = func(a) { math.cos(a * math.pi / 180.0) }
var sin = func(a) math.sin(a * D2R);
var cos = func(a) math.cos(a * D2R);
var sigmoid = func(x) { 1 / (1 + math.exp(-x)) }
var nsigmoid = func(x) { 2 / (1 + math.exp(-x)) - 1 }
var pow = func(v, w) { v < 0 ? nil : v == 0 ? 0 : math.exp(math.ln(v) * w) }

View file

@ -17,12 +17,12 @@
# Coord.lat()
# Coord.lon() ... functions for getting lat/lon/alt
# Coord.alt() ... returns altitude in m
# Coord.latlon() ... returns array [<lat>, <lon>, <alt>]
# Coord.latlon() ... returns vector [<lat>, <lon>, <alt>]
#
# Coord.x() ... functions for reading cartesian coords (in m)
# Coord.y()
# Coord.z()
# Coord.xyz() ... returns array [<x>, <y>, <z>]
# Coord.xyz() ... returns vector [<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
@ -211,7 +211,7 @@ var normdeg = func(angle) {
}
var bucket_span = func(lat) {
var _bucket_span = func(lat) {
if (lat >= 89.0)
360.0;
elsif (lat >= 88.0)
@ -248,7 +248,7 @@ var bucket_span = func(lat) {
var tile_index = func(lat, lon) {
var lat_floor = floor(lat);
var lon_floor = floor(lon);
var span = bucket_span(lat);
var span = _bucket_span(lat);
var x = 0;
if (span < 0.0000001) {
@ -291,7 +291,7 @@ var _put_model = func(path, lat, lon, elev_m = nil, hdg = 0, pitch = 0, roll = 0
if (elev_m == nil)
elev_m = elevation(lat, lon);
if (elev_m == nil)
die("geo.put_model(): can't get elevation for " ~ lat ~ "/" ~ lon);
die("geo.put_model(): cannot get elevation for " ~ lat ~ "/" ~ lon);
fgcommand("add-model", var n = props.Node.new({ "path": path,
"latitude-deg": lat, "longitude-deg": lon, "elevation-m": elev_m,
"heading-deg": hdg, "pitch-deg": pitch, "roll-deg": roll,

View file

@ -1,3 +1,11 @@
##
# Constants.
#
var D2R = math.pi / 180; # degree to radian
var R2D = 180 / math.pi; # radian to degree
var FT2M = 0.3048; # feet to meter
var M2FT = 1 / FT2M; # meter to feet
##
# Returns true if the first object is an instance of the second
# (class) object. Example: isa(someObject, props.Node)
@ -139,11 +147,3 @@ settimer(func {
io.load_nasal(path ~ "/" ~ file, substr(file, 0, size(file) - 4));
}, 0);
##
# Constants.
#
var D2R = math.pi / 180; # degree to radian
var R2D = 180 / math.pi; # radian to degree
var FT2M = 0.3048; # feet to meter
var M2FT = 1 / FT2M; # meter to feet