Current Page:
NeXtMidas Training
Macros - Part 1 (Basics)
Procedures and Subroutines
Lab 2* - Macro Procedures
Instructions
|
|
- Lab 2 - Macro Procedures:
- For this lab you will be writing a macro that takes in two sets of
latitude/longitude points (4 arguments) and computes the distance in
meters between them.
- The equation for this is:
d = MAG(v1 - v2)
where v1 and v2 are vectors in a CARTESIAN
coordinate system.
- Inside the macro, make a procedure to convert from GEODETIC
to CARTESIAN (The conversion must be done before subtraction).
The nxm.sys.lib.Position class contains a method to perform
the conversion.
- You will need to use the following commands:
NEW -- to create a Position object
INVOKE -- to invoke the method in Position to convert
from GEODETIC to CARTESIAN
CALC -- to compute the distance once the points are
converted to CARTESIAN
- When you are done use UPDATE to add MISS_DISTANCE
to the dictionary and try it out. The output should look similar to
this:
nM> miss_distance 44 33 45 34
Miss distance is 136644.17740578306 meters
- Hints:
- If you want have an output parameter from a procedure, you can
take in the result name and set the value of it like so:
call myProc 10 res1 ! Sets res1 result
call myProc 20 res2 ! Sets res2 result
...
procedure myProc N:in U:myOutputRes
result ^myOutputRes in
return
- You can convert the X,Y and Z values of a Position
object into a Midas
VD using the following
syntax:
nM> result myVector (pos.x,pos,y,pos.z)
where pos is a Position object.
- CALC can subtract vectors and get their magnitudes.
|
|
|