diff --git a/Source/SenseGloveUtils/Public/SGUtils/SGAngles.h b/Source/SenseGloveUtils/Public/SGUtils/SGAngles.h index 9b4e91fb..d9312701 100644 --- a/Source/SenseGloveUtils/Public/SGUtils/SGAngles.h +++ b/Source/SenseGloveUtils/Public/SGUtils/SGAngles.h @@ -42,6 +42,11 @@ class SENSEGLOVEUTILS_API FSGAngles final { public: + static FORCEINLINE float TransformToSenseGlove(const float Degrees) + { + return FMath::DegreesToRadians(Degrees); + } + static FORCEINLINE constexpr float TransformToSenseGlove(const int32 Movement, const float Direction) { // 0 = twist, 1 = flexion/extension, 2 = abduction @@ -59,6 +64,11 @@ public: 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) { /// TODO diff --git a/Source/SenseGloveUtils/Public/SGUtils/SGArrayUtils.h b/Source/SenseGloveUtils/Public/SGUtils/SGArrayUtils.h index 5304325c..b9f70e54 100644 --- a/Source/SenseGloveUtils/Public/SGUtils/SGArrayUtils.h +++ b/Source/SenseGloveUtils/Public/SGUtils/SGArrayUtils.h @@ -610,6 +610,31 @@ public: return MoveTemp(NestedVector); } + static std::vector ToSenseGloveAngles(const TArray& Array) + { + std::vector Vector; + + for (const float Value: Array) + { + Vector.emplace_back(FSGAngles::TransformToSenseGlove(Value)); + } + + return MoveTemp(Vector); + } + + static std::vector> ToSenseGloveAngles(const TArray>& NestedArray) + { + std::vector> NestedVector; + + for (const TArray& InnerArray: NestedArray) + { + std::vector InnerVector{ToSenseGloveAngles(InnerArray)}; + NestedVector.emplace_back(MoveTemp(InnerVector)); + } + + return MoveTemp(NestedVector); + } + template static std::vector ToSenseGloveAngles(const TArray& Array) { @@ -637,6 +662,31 @@ public: return MoveTemp(NestedVector); } + static TArray FromSenseGloveAngles(const std::vector& Vector) + { + TArray Array; + + for (const float Value: Vector) + { + Array.Add(FSGAngles::TransformToUnreal(Value)); + } + + return MoveTemp(Array); + } + + static TArray> FromSenseGloveAngles(const std::vector>& NestedVector) + { + TArray> Array; + + for (const std::vector& InnerVector: NestedVector) + { + TArray InnerArray{FromSenseGloveAngles(InnerVector)}; + Array.Add(MoveTemp(InnerArray)); + } + + return MoveTemp(Array); + } + template static TArray FromSenseGloveAngles(const std::vector& Vector) {