91 lines
2.2 KiB
C++
91 lines
2.2 KiB
C++
// Copyright Team Lumi. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "UniStrokeRectangle.h"
|
|
#include "UniStrokePoint.generated.h"
|
|
|
|
static const float Phi = 0.5f * (-1.0f + FMath::Sqrt(5.0f));
|
|
|
|
USTRUCT()
|
|
struct WIZARDINGCENTRAL_API FUniStrokePoint
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
FUniStrokePoint();
|
|
FUniStrokePoint(const float& X, const float& Y);
|
|
~FUniStrokePoint() = default;
|
|
|
|
static void
|
|
Resample(TArray<FUniStrokePoint>& Points,
|
|
const int& Num);
|
|
|
|
static float
|
|
PathLength(const TArray<FUniStrokePoint>& Points);
|
|
|
|
static void
|
|
RotateToZero(TArray<FUniStrokePoint>& Points);
|
|
|
|
static void
|
|
RotateBy(TArray<FUniStrokePoint>& Points,
|
|
const float& Theta);
|
|
|
|
static void
|
|
ScaleToSquare(TArray<FUniStrokePoint>& Points,
|
|
const float& Size);
|
|
|
|
static void
|
|
TranslateTo(TArray<FUniStrokePoint>& Points,
|
|
const FUniStrokePoint& Point);
|
|
|
|
static void
|
|
TranslateToOrigin(TArray<FUniStrokePoint>& Points);
|
|
|
|
static float
|
|
DistanceAtBestAngle(const TArray<FUniStrokePoint>& Points,
|
|
const TArray<FUniStrokePoint>& T,
|
|
const float& ThetaFrom,
|
|
const float& ThetaTo,
|
|
const float& ThetaThreshold);
|
|
|
|
static float
|
|
DistanceAtAngle(const TArray<FUniStrokePoint>& Points,
|
|
const TArray<FUniStrokePoint>& T,
|
|
const float& Theta);
|
|
|
|
static float
|
|
PathDistance(const TArray<FUniStrokePoint>& PathA,
|
|
const TArray<FUniStrokePoint>& PathB);
|
|
|
|
/**
|
|
* Converts a TArray of FVector2D to a TArray of FUniStrokePoint
|
|
*
|
|
* @param Points The points to convert
|
|
* @return The converted points as a TArray of FUniStrokePoint
|
|
*/
|
|
static TArray<FUniStrokePoint>
|
|
From(const TArray<FVector2D>& Points);
|
|
|
|
static float
|
|
Distance(const FUniStrokePoint& PointA,
|
|
const FUniStrokePoint& PointB);
|
|
|
|
static FUniStrokePoint
|
|
Centroid(const TArray<FUniStrokePoint>& Points);
|
|
|
|
static FUniStrokeRectangle
|
|
BoundingBox(const TArray<FUniStrokePoint>& Points);
|
|
|
|
static float
|
|
OptimalCosineDistance(const TArray<float>& VectorA,
|
|
const TArray<float>& VectorB);
|
|
|
|
static TArray<float>
|
|
Vectorize(const TArray<FUniStrokePoint>& Points);
|
|
|
|
private:
|
|
float X;
|
|
float Y;
|
|
};
|