How Do I Calculate the Distance Between Two Points?

« Go Back

Information

 
QuestionHow do I calculate the distance between two points on the ground?
Answer

There are several ways to calculate the distance between two points in STK, as described below.

Using STK objects

If an STK object traverses the distances between the two points in question, you can use the built-in data providers to report out the distance. For great arc vehicles (aircraft, ground vehicle, ship), you can create a custom report that contains the Distance Data Provider. For a missile or launch vehicle, you can create a custom report that contains the Ground Range Data Provider.

Using the 2D or 3D windows

STK has a ruler feature on both the 2D and 3D windows that enables you to simply click the two points of interest. The STK Message Viewer then reports the points clicked, the distance between them, and the bearing from the first to the second point.

Using the Programming Interface

Independent of any STK object, the "MeasureSurfaceDistance" Connect command gets you the distance between two points on the ground. You can send the Connect command through either of these: 

•  A command tool
  1. Open the View menu and select Web Browser.
  2. Click the Browse icon in the Web Browser toolbar.
  3. Click Example HTML Utilities in the Open dialog box.
  4. Go to STK Automation > API Demo and select the API Demo Utility.htm.
The Button Tool: Go to C:\Program Files\AGI\STK 12\Connect\Button_Tool\bin\PC\ButtonTool.exe.
AGI PC EXP Tool: Go to C:\Program Files\AGI\STK 12\bin\AGIPCEXP.exe.

OR

•  An object model program (MATLAB, C#, Java, Python, etc.)


If you are new to the programming interfaces of STK, please check out the STK Programming Help.

Here is an example, written in MATLAB. First, you will need to connect to a running instance of STK; then send a Connect command. To send Connect commands in MATLAB, use the root.ExecuteCommand. This will use the object model to send a Connect command and will return a set of results. An example of the initialization code is:

app = actxGetRunningServer('STK12.application');
root = app.Personality2;
root.ExecuteCommand('cmd text goes here')


Next, send the MeasureSurfaceDistance command, which requires latitude-longitude locations for both points. The command will return the distance, in the units of the Connect interface. Then you can pull the results using .Item(n), where n is a number that starts at 0 and goes to count-1 (in the case for MATLAB). In this case, there is only one result, so use the value 0. For example, you can find the distance between (10,10) and (20,20) on Earth. 

distance = root.ExecuteCommand('MeasureSurfaceDistance * 10 10 20 20 Earth');
distance_Value = distance.Item(0)


distance_Value is the distance between two latitude-longitude pairs, which for (10,10) and (20,20) is 1541856.434 m. 

TitleHow Do I Calculate the Distance Between Two Points?
URL NameMatlab-How-to-calculate-distance-between-two-points

Related Files