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 22:47:13 浏览: 56
这是一段 Unreal Engine 代码,定义了两个结构体:`FGeoCorners` 和 `FGeoBoundingBox`。
`FGeoCorners` 结构体包含了四个属性:`UpLeft`,`UpRight`,`DownLeft`,`DownRight`,这些属性是类型为 `FGeoPosition` 的结构体。它还包含一个名为 `ToBoundingBox` 的函数,用于转换为 `FGeoBoundingBox` 类型的结构体。
`FGeoBoundingBox` 结构体包含了两个属性:`MinLocation` 和 `MaxLocation`,这些属性也是类型为 `FGeoPosition` 的结构体。它还包含了两个构造函数,分别是默认构造函数和带参数的构造函数。
相关问题
UE C++ 蓝图 数据结构
UE C++蓝图数据结构是通过结构体和类来定义的。可以通过将现有的蓝图结构体引用,手动替换成新的C++结构体变量来实现。首先,在.h文件中声明结构体,并使用USTRUCT(BlueprintType)宏进行标记。然后使用UPROPERTY宏定义结构体的成员变量。接下来,在.cpp文件中使用GENERATED_BODY()宏生成结构体的代码。同样的,可以创建一个继承于UObject的C++类来定义蓝图数据结构。
示例代码如下:
```cpp
// .h文件
#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "QuestInfo.generated.h"
USTRUCT(BlueprintType)
struct BLUEPRINTSTOCPP_API FQuestInfo
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString Name;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName QuestId;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 Progress;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 ProgressTotal;
};
UCLASS()
class BLUEPRINTSTOCPP_API UQuestInfo : public UObject
{
GENERATED_BODY()
};
```
如何让OpenMV发送uint8_t类型的数据1
要让OpenMV发送uint8_t类型的数据1,您可以使用OpenMV的UART通信功能和MicroPython的内置函数进行操作。以下是一个示例代码,它使用UART发送一个uint8_t类型的数据1:
```python
import ustruct
import pyb
# 配置UART
uart = pyb.UART(3, 115200, timeout_char=1000)
# 发送数据
data = ustruct.pack('<B', 1) # 将一个uint8_t类型的数据1打包为字节数组
uart.write(data) # 发送字节数组
```
在这个示例代码中,我们首先使用`pyb.UART`类配置UART通信。然后,我们使用`ustruct.pack()`函数将一个uint8_t类型的数据1打包为字节数组。这里我们使用`<B`格式说明符,它表示一个无符号字节(即uint8_t)。最后,我们使用`uart.write()`函数发送字节数组。