add more utility functions and templates for angles, specifically for handling floats
This commit is contained in:
@@ -42,6 +42,11 @@
|
|||||||
class SENSEGLOVEUTILS_API FSGAngles final
|
class SENSEGLOVEUTILS_API FSGAngles final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static FORCEINLINE float TransformToSenseGlove(const float Degrees)
|
||||||
|
{
|
||||||
|
return FMath::DegreesToRadians(Degrees);
|
||||||
|
}
|
||||||
|
|
||||||
static FORCEINLINE constexpr float TransformToSenseGlove(const int32 Movement, const float Direction)
|
static FORCEINLINE constexpr float TransformToSenseGlove(const int32 Movement, const float Direction)
|
||||||
{
|
{
|
||||||
// 0 = twist, 1 = flexion/extension, 2 = abduction
|
// 0 = twist, 1 = flexion/extension, 2 = abduction
|
||||||
@@ -59,6 +64,11 @@ public:
|
|||||||
return FMath::DegreesToRadians(V(Vector.X * -1.0f, Vector.Z, Vector.Y));
|
return FMath::DegreesToRadians(V(Vector.X * -1.0f, Vector.Z, Vector.Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static FORCEINLINE float TransformToUnreal(const float Radians)
|
||||||
|
{
|
||||||
|
return FMath::RadiansToDegrees(Radians);
|
||||||
|
}
|
||||||
|
|
||||||
static FORCEINLINE constexpr float TransformToUnreal(const int32 Movement, const float Direction)
|
static FORCEINLINE constexpr float TransformToUnreal(const int32 Movement, const float Direction)
|
||||||
{
|
{
|
||||||
/// TODO
|
/// TODO
|
||||||
|
|||||||
@@ -610,6 +610,31 @@ public:
|
|||||||
return MoveTemp(NestedVector);
|
return MoveTemp(NestedVector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::vector<float> ToSenseGloveAngles(const TArray<float>& Array)
|
||||||
|
{
|
||||||
|
std::vector<float> Vector;
|
||||||
|
|
||||||
|
for (const float Value: Array)
|
||||||
|
{
|
||||||
|
Vector.emplace_back(FSGAngles::TransformToSenseGlove(Value));
|
||||||
|
}
|
||||||
|
|
||||||
|
return MoveTemp(Vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::vector<std::vector<float>> ToSenseGloveAngles(const TArray<TArray<float>>& NestedArray)
|
||||||
|
{
|
||||||
|
std::vector<std::vector<float>> NestedVector;
|
||||||
|
|
||||||
|
for (const TArray<float>& InnerArray: NestedArray)
|
||||||
|
{
|
||||||
|
std::vector<float> InnerVector{ToSenseGloveAngles(InnerArray)};
|
||||||
|
NestedVector.emplace_back(MoveTemp(InnerVector));
|
||||||
|
}
|
||||||
|
|
||||||
|
return MoveTemp(NestedVector);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename V3D>
|
template<typename V3D>
|
||||||
static std::vector<V3D> ToSenseGloveAngles(const TArray<FVector>& Array)
|
static std::vector<V3D> ToSenseGloveAngles(const TArray<FVector>& Array)
|
||||||
{
|
{
|
||||||
@@ -637,6 +662,31 @@ public:
|
|||||||
return MoveTemp(NestedVector);
|
return MoveTemp(NestedVector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static TArray<float> FromSenseGloveAngles(const std::vector<float>& Vector)
|
||||||
|
{
|
||||||
|
TArray<float> Array;
|
||||||
|
|
||||||
|
for (const float Value: Vector)
|
||||||
|
{
|
||||||
|
Array.Add(FSGAngles::TransformToUnreal(Value));
|
||||||
|
}
|
||||||
|
|
||||||
|
return MoveTemp(Array);
|
||||||
|
}
|
||||||
|
|
||||||
|
static TArray<TArray<float>> FromSenseGloveAngles(const std::vector<std::vector<float>>& NestedVector)
|
||||||
|
{
|
||||||
|
TArray<TArray<float>> Array;
|
||||||
|
|
||||||
|
for (const std::vector<float>& InnerVector: NestedVector)
|
||||||
|
{
|
||||||
|
TArray<float> InnerArray{FromSenseGloveAngles(InnerVector)};
|
||||||
|
Array.Add(MoveTemp(InnerArray));
|
||||||
|
}
|
||||||
|
|
||||||
|
return MoveTemp(Array);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename V3D>
|
template<typename V3D>
|
||||||
static TArray<FVector> FromSenseGloveAngles(const std::vector<V3D>& Vector)
|
static TArray<FVector> FromSenseGloveAngles(const std::vector<V3D>& Vector)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user