This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Geodetic script

Unigine allows you to convert coordinates between different coordinate systems by using the Geodetic script. This script enables easier usage of real-world GIS data in UNIGINE-powered projects. Unigine uses Cartesian coordinate system.

This article shows the principles of the Unigine Geodetic class. Geodetic class located in data/core/scripts/geodetic.h.

See Also

Overview

The World Geodetic System (WGS 84) is currently a standard for use in geodesy, navigation and so on. By using the Geodetic script, you can easily convert WGS 84 coordinates to Cartesian which are used in the Unigine engine.

The WGS coordinate system uses latitude, longitude and altitude (height).

Unigine converts WGS coordinates to the Earth-Centered, Earth-Fixed (ECF) Cartesian coordinate system. Script sets the origin of the WGS coordinate system and convert it to the origin of the ECF coordinate system to make further conversion. Also, script calculates the rotation matrix (and inverse rotation matrix) to make coordinates oriented in the right way.

The ECF coordinate system uses the center of the Earth as an origin. Unigine converts WGS origin to the ECF origin (local).

Converting to ECF is an intermediate step, Unigine converts ECF coordinates to North east down (NED) coordinate system. The NED coordinate system is commonly used in aviation, and if you used it in your project, you'll get a negative value along the Z axis.

To convert them to Unigine, you just need to reverse z and x (to keep the coordinate system right handed) NED coordinates.

Formula
Unigine.xyz = (-NED.x, NED.y, -NED.z)

The resulting execution sequence is the following: WCG -> ECF -> NED and optionally, you can convert NED coordinates to Unigine.

Workflow

This section describes the workflow of the typical usage example. To place the object on the already created terrain, you should do the following:

  1. Set the WGS origin. You can set it by using one of the Geodetic class constructors or by using the setWGSOrigin() function.
  2. Get the NED position of the object by using the getNEDPosition() function.
    Notice
    You can use NED coordinates or convert it to Unigine by using formula given above.
  3. Set the calculated position to the object to place it.
Last update: 2017-07-03
Build: ()