Hello, I want to obtain the center point of the Earth and convert it into a Unity coordinate system. How can I obtain it? How to convert?
The center of the Earth is simply (0,0,0) in the Earth-Centered, Earth-Fixed (ECEF) coordinate system. You can convert ECEF to Unity coordinates using TransformEarthCenteredEarthFixedPositionToUnity
on the CesiumGeoreference
component.
See here:L
/// <summary>
/// Transform an Earth-Centered, Earth-Fixed position to Unity coordinates. The resulting position should generally
/// not be interpreted as a Unity _world_ position, but rather a position expressed in some parent
/// GameObject's reference frame as defined by its Transform. This way, the chain of Unity transforms
/// places and orients the "globe" in the Unity world.
/// </summary>
/// <param name="earthCenteredEarthFixed">The ECEF coordinates in meters.</param>
/// <returns>The corresponding Unity coordinates.</returns>
public double3
TransformEarthCenteredEarthFixedPositionToUnity(double3 earthCenteredEarthFixed)
{
this.Initialize();
return math.mul(this._ecefToLocal, new double4(earthCenteredEarthFixed, 1.0)).xyz;
}
/// <summary>
/// Transform a Unity direction to a direction in Earth-Centered, Earth-Fixed (ECEF) coordinates. The
/// direction should generally not be a Unity _world_ direction, but rather a direction expressed in
/// some parent GameObject's reference frame as defined by its Transform. This way, the chain of
/// Unity transforms orients the "globe" in the Unity world.