shown in other instead.
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.
- The Geodetic class functions.
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.
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.
This section describes the workflow of the typical usage example. To place the object on the already created terrain, you should do the following:
- Set the WGS origin. You can set it by using one of the Geodetic class constructors or by using the setWGSOrigin() function.
Get the NED position of the object by using the getNEDPosition() function.
You can use NED coordinates or convert it to Unigine by using formula given above.
- Set the calculated position to the object to place it.