Cesium for Unreal 2.13.2
Loading...
Searching...
No Matches
CesiumEllipsoid.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "Engine/DataAsset.h"
6#include "Misc/Optional.h"
7#include <CesiumGeospatial/LocalHorizontalCoordinateSystem.h>
8#include "CesiumEllipsoid.generated.h"
9
10namespace CesiumGeospatial {
11class Ellipsoid;
12};
13
14UCLASS()
15class CESIUMRUNTIME_API UCesiumEllipsoid : public UDataAsset {
16 GENERATED_BODY()
17
18public:
19 /**
20 * Creates a new {@link UCesiumEllipsoid} with the given radii.
21 *
22 * This is equivalent to
23 * ```
24 * auto ellipsoid = NewObject<UCesiumEllipsoid>();
25 * ellipsoid->SetRadii(Radii);
26 * ```
27 */
28 UFUNCTION(BlueprintCallable, Category = "Cesium|Ellipsoid")
29 static UCesiumEllipsoid* Create(const FVector& Radii);
30
31 /**
32 * Gets the radii of the ellipsoid in its x-, y-, and z-directions in
33 * meters.
34 */
35 UFUNCTION(BlueprintPure, Category = "Cesium|Ellipsoid")
36 FVector GetRadii();
37
38 /**
39 * Sets the radii of this ellipsoid in its x-, y-, and z-directions in meters.
40 *
41 * Tilesets using this ellipsoid may have to be refreshed to see the changes
42 * applied.
43 */
44 void SetRadii(const FVector& NewRadii);
45
46 /**
47 * Gets the maximum radius of the ellipsoid in any dimension, in meters.
48 */
49 UFUNCTION(BlueprintPure, Category = "Cesium|Ellipsoid")
50 double GetMaximumRadius();
51
52 /**
53 * Gets the minimum radius of the ellipsoid in any dimension, in
54 * meters.
55 */
56 UFUNCTION(BlueprintPure, Category = "Cesium|Ellipsoid")
57 double GetMinimumRadius();
58
59 /**
60 * Scale the given Ellipsoid-Centered, Ellipsoid-Fixed position along the
61 * geodetic surface normal so that it is on the surface of the ellipsoid. If
62 * the position is near the center of the ellipsoid, the result will have the
63 * value (0,0,0) because the surface position is undefined.
64 */
65 UFUNCTION(
66 BlueprintPure,
67 Category = "Cesium|Ellipsoid",
68 meta = (ReturnDisplayName = "SurfacePosition"))
69 FVector
70 ScaleToGeodeticSurface(const FVector& EarthCenteredEarthFixedPosition);
71
72 /**
73 * Computes the normal of the plane tangent to the surface of the ellipsoid
74 * at the provided Ellipsoid-Centered, Ellipsoid-Fixed position.
75 */
76 UFUNCTION(
77 BlueprintPure,
78 Category = "Cesium|Ellipsoid",
79 meta = (ReturnDisplayName = "SurfaceNormalVector"))
80 FVector GeodeticSurfaceNormal(const FVector& EarthCenteredEarthFixedPosition);
81
82 /**
83 * Convert longitude in degrees (X), latitude in degrees (Y), and height above
84 * the ellipsoid in meters (Z) to Ellipsoid-Centered, Ellipsoid-Fixed (ECEF)
85 * coordinates.
86 */
87 UFUNCTION(
88 BlueprintPure,
89 Category = "Cesium|Ellipsoid",
90 meta = (ReturnDisplayName = "EarthCenteredEarthFixedPosition"))
91 FVector LongitudeLatitudeHeightToEllipsoidCenteredEllipsoidFixed(
92 const FVector& LongitudeLatitudeHeight);
93
94 /**
95 * Convert Ellipsoid-Centered, Ellipsoid-Fixed (ECEF) coordinates to longitude
96 * in degrees (X), latitude in degrees (Y), and height above the ellipsoid in
97 * meters (Z). If the position is near the center of the Ellipsoid, the result
98 * will have the value (0,0,0) because the longitude, latitude, and height are
99 * undefined.
100 */
101 UFUNCTION(
102 BlueprintPure,
103 Category = "Cesium|Ellipsoid",
104 meta = (ReturnDisplayName = "LongitudeLatitudeHeight"))
105 FVector EllipsoidCenteredEllipsoidFixedToLongitudeLatitudeHeight(
106 const FVector& EarthCenteredEarthFixedPosition);
107
108 /**
109 * Computes the transformation matrix from the local East-North-Up (ENU) frame
110 * to Ellipsoid-Centered, Ellipsoid-Fixed (ECEF) at the specified ECEF
111 * location.
112 */
113 FMatrix EastNorthUpToEllipsoidCenteredEllipsoidFixed(
114 const FVector& EarthCenteredEarthFixedPosition);
115
116 /**
117 * Returns a new {@link CesiumGeospatial::LocalHorizontalCoordinateSystem}
118 * with the given scale, center, and ellipsoid.
119 */
120 CesiumGeospatial::LocalHorizontalCoordinateSystem
121 CreateCoordinateSystem(const FVector& Center, double Scale);
122
123 /**
124 * Returns the underlying {@link CesiumGeospatial::Ellipsoid}
125 */
126 const CesiumGeospatial::Ellipsoid& GetNativeEllipsoid();
127
128protected:
129 /**
130 * The radii of this ellipsoid.
131 *
132 * The X coordinate of the vector should be the radius of the largest axis and
133 * the Z coordinate should be the radius of the smallest axis.
134 */
135 UPROPERTY(
136 EditAnywhere,
137 Category = "Cesium|Ellipsoid",
138 meta = (DisplayName = "Radii"))
139 FVector Radii;
140
141private:
142#if WITH_EDITOR
143 virtual void
144 PostSaveRoot(FObjectPostSaveRootContext ObjectSaveContext) override;
145#endif
146
147 TOptional<CesiumGeospatial::Ellipsoid> NativeEllipsoid;
148};