ArcGIS Runtime SDK for Java

Calculate Distance 3D

Demonstrates how to calculate the distance, in meters, between two Graphics in 3D space.

How it works

To calculate the distance between two Graphics in 3D space:

  1. Create a GraphicsOverlay and attach it to the SceneView.
  2. Create the two graphics and add to graphics overlay.

    • supply each graphic with a Point, starting location, and SimpleMarkerSymbol

  3. Convert each graphic's point to the Cartesian coordinate system
  4. Create a JavaFX Point3D from the Cartesian x,y, and z value.
  5. Then get the distance between each of the JavaFX Point3Ds, Point3D.distance(Point3D).


 * Copyright 2017 Esri.
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.

package com.esri.samples.scene.calculate_distance_3d;


import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class CalculateDistance3dSample extends Application {

  private static CalculateDistance3dController controller;

  public void start(Stage stage) throws IOException {
    // set up the scene
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/calculate_distance_3d.fxml"));
    Parent root = loader.load();
    controller = loader.getController();
    Scene scene = new Scene(root);

    // set up the stage
    stage.setTitle("Calculate Distance 3d Sample");

   * Stops and releases all resources used in application.
  public void stop() {

   * Opens and runs application.
   * @param args arguments passed to this application
  public static void main(String[] args) {


In this topic
  1. How it works
  2. Code