USTRUCT(BlueprintType) struct MPBASE_API FGeoCorners { GENERATED_BODY() UPROPERTY(EditAnywhere, Category = "GeoTypes | Corners") FGeoPosition UpLeft; UPROPERTY(EditAnywhere, Category = "GeoTypes | Corners") FGeoPosition UpRight; UPROPERTY(EditAnywhere, Category = "GeoTypes | Corners") FGeoPosition DownLeft; UPROPERTY(EditAnywhere, Category = "GeoTypes | Corners") FGeoPosition DownRight; FGeoBoundingBox ToBoundingBox() const; }; USTRUCT(BlueprintType) struct MPBASE_API FGeoBoundingBox { GENERATED_BODY() UPROPERTY(EditAnywhere, Category = "GeoTypes | BoundingBox") FGeoPosition MinLocation; UPROPERTY(EditAnywhere, Category = "GeoTypes | BoundingBox") FGeoPosition MaxLocation; FGeoBoundingBox() = default; FGeoBoundingBox(double minx, double miny, double maxx, double maxy) : MinLocation(minx, miny), MaxLocation(maxx, maxy) { } FGeoBoundingBox(const FGeoPosition& minLoc, const FGeoPosition& maxLoc) : MinLocation(minLoc), MaxLocation(maxLoc) { } bool IsValid() const { return MinLocation.IsValid() && MaxLocation.IsValid() && MinLocation <= MaxLocation; } bool Contains(const FGeoPosition& location) const { return location.Longitude >= MinLocation.Longitude && location.Latitude >= MinLocation.Latitude && location.Longitude <= MaxLocation.Longitude && location.Latitude <= MaxLocation.Latitude; } FGeoBoundingBox& operator+=(const FGeoPosition& Location); FGeoBoundingBox& operator+=(const FGeoBoundingBox& GeoBox); bool Intersect(const FGeoBoundingBox& Other) const; bool Contains(const FGeoBoundingBox& Other) const; FGeoBoundingBox Intersection(const FGeoBoundingBox& Other) const; bool IsInside(const FGeoPosition & TestPoint) const { return ((TestPoint.Longitude > MinLocation.Longitude) && (TestPoint.Longitude < MaxLocation.Longitude) && (TestPoint.Latitude > MinLocation.Latitude) && (TestPoint.Latitude < MaxLocation.Latitude)); } bool IsInside(const FGeoBoundingBox& Other) const { return (IsInside(Other.MinLocation) && IsInside(Other.MaxLocation)); } FGeoPosition GetCenter() const; FGeoCorners ToCorners() const; double GetDeltaLongitude() const { return MaxLocation.Longitude - MinLocation.Longitude; } double GetDeltaLatitude() const { return MaxLocation.Latitude - MinLocation.Latitude; } };代码含义
时间: 2023-02-25 18:47:13 浏览: 116
UStruct-开源
这是一段 Unreal Engine 代码,定义了两个结构体:`FGeoCorners` 和 `FGeoBoundingBox`。
`FGeoCorners` 结构体包含了四个属性:`UpLeft`,`UpRight`,`DownLeft`,`DownRight`,这些属性是类型为 `FGeoPosition` 的结构体。它还包含一个名为 `ToBoundingBox` 的函数,用于转换为 `FGeoBoundingBox` 类型的结构体。
`FGeoBoundingBox` 结构体包含了两个属性:`MinLocation` 和 `MaxLocation`,这些属性也是类型为 `FGeoPosition` 的结构体。它还包含了两个构造函数,分别是默认构造函数和带参数的构造函数。
阅读全文