Cesium for Unreal 2.12.0
Loading...
Searching...
No Matches
GeoTransforms.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "CesiumGeospatial/Ellipsoid.h"
6#include "CesiumGeospatial/LocalHorizontalCoordinateSystem.h"
7#include "HAL/Platform.h"
8#include "Math/Matrix.h"
9#include <glm/fwd.hpp>
10#include <glm/vec3.hpp>
11
21class CESIUMRUNTIME_API GeoTransforms {
22
23public:
28
40 const CesiumGeospatial::Ellipsoid& ellipsoid,
41 const glm::dvec3& center,
42 double scale);
43
52 void setCenter(const glm::dvec3& center) noexcept;
53
59 void setEllipsoid(const CesiumGeospatial::Ellipsoid& ellipsoid) noexcept;
60
67 const glm::dvec3& LongitudeLatitudeHeight) const noexcept;
68
74 glm::dvec3
75 TransformEcefToLongitudeLatitudeHeight(const glm::dvec3& Ecef) const noexcept;
76
83 const glm::dvec3& origin,
84 const glm::dvec3& LongitudeLatitudeHeight) const noexcept;
85
92 const glm::dvec3& origin,
93 const glm::dvec3& Ue) const noexcept;
94
100 const glm::dvec3& origin,
101 const glm::dvec3& Ecef) const noexcept;
102
108 const glm::dvec3& origin,
109 const glm::dvec3& Ue) const noexcept;
110
116 const glm::dvec3& origin,
117 const glm::dquat& UeRotator,
118 const glm::dvec3& UeLocation) const noexcept;
119
125 const glm::dvec3& origin,
126 const glm::dquat& EnuRotator,
127 const glm::dvec3& UeLocation) const noexcept;
128
136 const glm::dvec3& origin,
137 const glm::dvec3& Ue) const noexcept;
138
143 glm::dmat3 ComputeEastNorthUpToEcef(const glm::dvec3& Ecef) const noexcept;
144
145 /*
146 * GEOREFERENCE TRANSFORMS
147 */
148
158 const glm::dmat4&
160 return this->_coordinateSystem.getLocalToEcefTransformation();
161 }
162
172 const glm::dmat4&
174 return this->_coordinateSystem.getEcefToLocalTransformation();
175 }
176
185 glm::dvec3 ComputeGeodeticSurfaceNormal(const glm::dvec3& position) const {
186 return _ellipsoid.geodeticSurfaceNormal(position);
187 }
188
201 const glm::dvec3& oldPosition,
202 const glm::dvec3& newPosition) const;
203
216 const glm::dvec3& oldPosition,
217 const glm::dvec3& newPosition) const;
218
220 return this->_ecefToUnreal;
221 }
223 return this->_unrealToEcef;
224 }
225
226private:
231 void updateTransforms() noexcept;
232
233 CesiumGeospatial::LocalHorizontalCoordinateSystem _coordinateSystem;
234
235 // Modifiable state
236 CesiumGeospatial::Ellipsoid _ellipsoid;
237 glm::dvec3 _center;
238 double _scale;
239 FMatrix _ecefToUnreal;
240 FMatrix _unrealToEcef;
241};
A lightweight structure to encapsulate coordinate transforms.
glm::dquat ComputeSurfaceNormalRotationUnreal(const glm::dvec3 &oldPosition, const glm::dvec3 &newPosition) const
Computes the rotation in ellipsoid surface normal between an old position and a new position.
GeoTransforms()
Creates a new instance.
glm::dquat ComputeSurfaceNormalRotation(const glm::dvec3 &oldPosition, const glm::dvec3 &newPosition) const
Computes the rotation in ellipsoid surface normal between an old position and a new position.
glm::dvec3 ComputeGeodeticSurfaceNormal(const glm::dvec3 &position) const
Computes the normal of the plane tangent to the surface of the ellipsoid that is used by this instanc...
const FMatrix & GetEllipsoidCenteredToAbsoluteUnrealWorldMatrix() const
void setCenter(const glm::dvec3 &center) noexcept
Set the center position of this instance.
glm::dvec3 TransformUnrealToEcef(const glm::dvec3 &origin, const glm::dvec3 &Ue) const noexcept
Transforms the given point from Unreal world coordinates (relative to the floating origin) to Earth-C...
glm::dvec3 TransformLongitudeLatitudeHeightToUnreal(const glm::dvec3 &origin, const glm::dvec3 &LongitudeLatitudeHeight) const noexcept
Transforms the given longitude in degrees (x), latitude in degrees (y), and height in meters (z) into...
const glm::dmat4 & GetAbsoluteUnrealWorldToEllipsoidCenteredTransform() const noexcept
Gets the transformation from the absolute "Unreal World" reference frame to the "Ellipsoid-centered" ...
glm::dvec3 TransformEcefToUnreal(const glm::dvec3 &origin, const glm::dvec3 &Ecef) const noexcept
Transforms the given point from Earth-Centered, Earth-Fixed (ECEF) into Unreal world coordinates (rel...
glm::dquat TransformRotatorUnrealToEastSouthUp(const glm::dvec3 &origin, const glm::dquat &UeRotator, const glm::dvec3 &UeLocation) const noexcept
Transforms a rotator from Unreal world to East-South-Up at the given Unreal relative world location (...
glm::dvec3 TransformLongitudeLatitudeHeightToEcef(const glm::dvec3 &LongitudeLatitudeHeight) const noexcept
Transforms the given longitude in degrees (x), latitude in degrees (y), and height in meters (z) into...
const FMatrix & GetAbsoluteUnrealWorldToEllipsoidCenteredMatrix() const
const glm::dmat4 & GetEllipsoidCenteredToAbsoluteUnrealWorldTransform() const noexcept
Gets the transformation from the "Ellipsoid-centered" reference frame (i.e.
void setEllipsoid(const CesiumGeospatial::Ellipsoid &ellipsoid) noexcept
Set the ellipsoid of this instance.
glm::dmat3 ComputeEastNorthUpToEcef(const glm::dvec3 &Ecef) const noexcept
Computes the rotation matrix from the local East-North-Up to Earth-Centered, Earth-Fixed (ECEF) at th...
glm::dvec3 TransformEcefToLongitudeLatitudeHeight(const glm::dvec3 &Ecef) const noexcept
Transforms the given Earth-Centered, Earth-Fixed (ECEF) coordinates into longitude in degrees (x),...
glm::dmat4 ComputeEastSouthUpToUnreal(const glm::dvec3 &origin, const glm::dvec3 &Ue) const noexcept
Computes the rotation matrix from the local East-South-Up to Unreal at the specified Unreal world loc...
glm::dquat TransformRotatorEastSouthUpToUnreal(const glm::dvec3 &origin, const glm::dquat &EnuRotator, const glm::dvec3 &UeLocation) const noexcept
Transforms a rotator from East-South-Up to Unreal world at the given Unreal world location (relative ...
glm::dvec3 TransformUnrealToLongitudeLatitudeHeight(const glm::dvec3 &origin, const glm::dvec3 &Ue) const noexcept
Transforms Unreal world coordinates (relative to the floating origin) into longitude in degrees (x),...
GeoTransforms(const CesiumGeospatial::Ellipsoid &ellipsoid, const glm::dvec3 &center, double scale)
Creates a new instance.