Nasal library/geo: Difference between revisions

Jump to navigation Jump to search
Finish [direct_]distance_to(), plus minor things
(Finish course_to())
(Finish [direct_]distance_to(), plus minor things)
Line 42: Line 42:
|param1text = The latitude coordinate, in degrees.
|param1text = The latitude coordinate, in degrees.
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
coord.set_latlon(0,0,0);
coord.set_latlon(0, 0, 0);
coord.set_lat(45);
coord.set_lat(45);
coord.dump();
coord.dump();
Line 54: Line 54:
|param1text = The longitude coordinate, in degrees.
|param1text = The longitude coordinate, in degrees.
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
coord.set_latlon(0,0,0);
coord.set_latlon(0, 0, 0);
coord.set_lon(90);
coord.set_lon(90);
coord.dump();
coord.dump();
Line 66: Line 66:
|param1text = The altitude coordinate. Note that this can be in either feet or metres, so make sure you convert correctly. Also note that in conversion, this coordinate will be assumed to be metres above equatorial radius of earth used is that defined by the {{wikipedia|WGS 84}} (6,378,137 metres).
|param1text = The altitude coordinate. Note that this can be in either feet or metres, so make sure you convert correctly. Also note that in conversion, this coordinate will be assumed to be metres above equatorial radius of earth used is that defined by the {{wikipedia|WGS 84}} (6,378,137 metres).
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
coord.set_latlon(0,0,0);
coord.set_latlon(0, 0, 0);
coord.set_alt(1000);
coord.set_alt(1000);
coord.dump();
coord.dump();
Line 96: Line 96:
|param1text = The mandatory x-axis coordinate, in metres.
|param1text = The mandatory x-axis coordinate, in metres.
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
coord.set_xyz(0,0,0);
coord.set_xyz(0, 0, 0);
coord.set_x(10);
coord.set_x(10);
coord.dump();
coord.dump();
Line 120: Line 120:
|param1text = The mandatory z-axis coordinate, in metres.
|param1text = The mandatory z-axis coordinate, in metres.
|example1 = var coord = geo.Coord.new();
|example1 = var coord = geo.Coord.new();
coord.set_xyz(0,0,0);
coord.set_xyz(0, 0, 0);
coord.set_y(10);
coord.set_y(10);
coord.dump();
coord.dump();
Line 239: Line 239:
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns the initial bearing (see [http://www.movable-type.co.uk/scripts/latlong.html#bearing here]) to another <code>geo.Coord</code> instance. The bearing will be in the range 0–360.
|text = Returns the initial bearing (see [http://www.movable-type.co.uk/scripts/latlong.html#bearing here]) to another <code>geo.Coord</code> instance. The bearing will be in the range 0–360.
|param1 = coord
|param1text = Mandatory <code>geo.Coord</code> instance to calculate bearing to.
|example1 = var c1 = geo.Coord.new();
|example1 = var c1 = geo.Coord.new();
c1.set_latlon(0, 0);
c1.set_latlon(0, 0);
Line 245: Line 247:
printf("%.5f", c1.course_to(c2)); # prints "44.99564"
printf("%.5f", c1.course_to(c2)); # prints "44.99564"
}}
}}
==== distance_to() ====
{{Nasal doc
|syntax = geo.Coord.distance_to(coord);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns the great circle distance in metres to another <code>geo.Coord</code> instance. Note that this function ignores altitude.
|param1 = coord
|param1text = Mandatory <code>geo.Coord</code> instance to calculate distance to.
|example1 = var c1 = geo.Coord.new();
c1.set_latlon(0, 0);
var c2 = geo.Coord.new();
c2.set_latlon(1, 1);
printf("%i", c1.distance_to(c2)); # prints "157425"
}}
==== direct_distance_to() ====
{{Nasal doc
|syntax = geo.Coord.direct_distance_to(coord);
|source = {{fgdata file|Nasal/geo.nas|t=Source}}
|text = Returns the direct distance (cutting through the earth) in metres to another <code>geo.Coord</code> instance.
|param1 = coord
|param1text = Mandatory <code>geo.Coord</code> instance to calculate distance to.
|example1 = var c1 = geo.Coord.new();
c1.set_latlon(0, 0);
var c2 = geo.Coord.new();
c2.set_latlon(45, 90);
printf("%i", c1.direct_distance_to(c2)); # prints "9012522"
}}
==== apply_course_distance() ====
=== PositionedSearch ===
=== PositionedSearch ===


Navigation menu