# World Space

How space is defined in eeGeo 3D maps

### Working with our World Space

eeGeo 3D Maps’ world space is large. It’s probably not a shock that it’s the size of the Earth. There are interesting challenges in creating a graphics application in such a large world space, specifically related to float precision. This section of the documentation explains our world space, how you work with it, and how to convert between it and other familiar spaces like Mercator.

**In this section:**

### ECEF

Our world space we call ECEF, it is a subtle variation of “Earth Centred Earth Fixed” that we find more appropriate.

- The origin (0,0,0) is the centre of mass of the earth.
- The positive X axis passes through the americas at LatLong(0, -90)
- The positive Y axis passes through the south north pole
- The positive Z axis passes through the prime meridian (0 longitude) at LatLong(0, 0)

For simplcity, we consider the earth a perfect sphere, of radius 6,378,100m.

Therefore, the exact ECEF position of the north pole, would be (0, 6378100.0, 0)

**The units are metres**

Visualised, the axis of our ECEF space look like:

### Lat,Long to ECEF

You can quickly convert between LatLong and ECEF using the LatLong and/or LatLongAltitude types found under the maths namespace:

1 2 3 4 |
double latitude = 50.0; double longitude = 4.0; Eegeo::Space::LatLong ll = Eegeo::Space::LatLong::FromDegrees(latitude, longitude); Eegeo::dv3 ecefPosition = ll.ToECEF(); |

Altitude in the LatLongAltitude type is measured in metres above the surface of the perfect sphere (which is considered sea level)

1 2 3 4 5 |
double latitude = 50.0; double longitude = 4.0; double heightAboveSeaLevel = 100.0; Eegeo::Space::LatLongAltitude lla = Eegeo::Space::LatLongAltitude(latitude, longitude, heightAboveSeaLevel, Eegeo::Space::LatLongUnits::Degrees); Eegeo::dv3 ecefPosition = lla.ToECEF(); |

### ECEF to Lat,Long

You can quickly convert between an ECEF Vector3D and a LatLongAltitude using the fromECEF static function on the LatLongAltitude type:

1 2 |
Eegeo::dv3 ecefOfNorthPole = Eegeo::dv3(0.0, 6378100.0, 0.0); Eegeo::Space::LatLongAltitude lla = Eegeo::Space::LatLongAltitude::FromECEF(ecefOfNorthPole); |

### ECEF Tangent Coordinate frame

Apps often need to position and orient objects in a coordinate frame that is tangential to the Earth’s surface. For some point on the Earth’s surface, the patch of the Earth sphere that is locally around that point is approximately flat. We can use this tangent plane to define a local coordinate system that is useful for positioning objects relative to this reference frame.

The “up” direction is perpendicular to the tangent plane – so is in the same direction as a ray from the Earth’s centre passing through our ECEF point on the sphere surface.

The “forward” and “right” directions lie on the tangent plane, perpendicular to each other.

Conventionally, we use a left-handed coordinate system, where:

- The
**positive X**axis points “right” - The
**positive Y**axis points “up” - The
**positive Z**axis points “forward”

We provide a class to assist in defining such as coordinate frame: EcefTangentBasis. This can be constructed from an ECEF point and a forward “heading” direction. The class uses these to create the 3 orthogonal basis direction vectors, constrained as described above.

### Positioning a Model

We provide a class to assist in defining such as coordinate frame: EcefTangentBasis. This can be constructed from an ECEF point and a forward “heading” direction. The class uses these to create the 3 orthogonal basis direction vectors, constrained as described above.

### Visual Debugging

The SDK provides a set of Debug Rendering methods to aid in the understanding of the ECEF coordinate system and help visually debug your scene. This includes methods for drawing lines, cubes, spheres and axes. The complete list of methods can be found on the DebugRenderer type, and an example demonstrating how to use both the DebugRenderer & an EcefTangentBasis is located in this Mobile SDK Harness Example.