rename sguitls/sgcoordinates utility class to sgangles and convert angles from radians to degrees and vice-versa between unreal and senseglove

This commit is contained in:
Mamadou Babaei
2023-03-28 10:39:49 +02:00
parent 8774369815
commit deae80f636
7 changed files with 37 additions and 35 deletions
@@ -38,8 +38,8 @@
#include "SGBuildHacks/SGInclude_Core_Anatomy.h"
#include "SGBuildHacks/SGInclude_Core_Vect3D.h"
#include "SGCoreImpl/SGVect3DImpl.h"
#include "SGUtils/SGAngles.h"
#include "SGUtils/SGArrayUtils.h"
#include "SGUtils/SGCoordinates.h"
float FSGAnatomyImpl::GetTotalFingerFlexion()
{
@@ -64,14 +64,14 @@ float FSGAnatomyImpl::GetTotalThumbExtension()
float FSGAnatomyImpl::GetFingerJointLimit(
const bool bRightHanded, const int32 Joint, const int32 Movement, const bool bMax)
{
return FSGCoordinates::TransformToUnreal(
return FSGAngles::TransformToUnreal(
Movement, FAnatomyType::GetFingerJointLimit(bRightHanded, Joint, Movement, bMax));
}
float FSGAnatomyImpl::GetThumbJointLimit(
const bool bRightHanded, const int32 Joint, const int32 Movement, const bool bMax)
{
return FSGCoordinates::TransformToUnreal(
return FSGAngles::TransformToUnreal(
Movement, FAnatomyType::GetThumbJointLimit(bRightHanded, Joint, Movement, bMax));
}
@@ -48,8 +48,8 @@
#include "SGCoreImpl/SGInterpolationSetImpl.h"
#include "SGCoreImpl/SGQuatImpl.h"
#include "SGCoreImpl/SGVect3DImpl.h"
#include "SGUtils/SGAngles.h"
#include "SGUtils/SGArrayUtils.h"
#include "SGUtils/SGCoordinates.h"
struct FSGHandInterpolatorImpl::FImpl
{
@@ -100,7 +100,7 @@ TArray<FVector> FSGHandInterpolatorImpl::InterpolateFingerAngles(
FSGArrayUtils::FromSenseGloveAngles<FSGVect3DImpl::FVect3DType>(
FHandInterpolatorType::InterpolateFingerAngles(
FSGCoreEnumCast::ToEFinger(Finger), Interpolator.ToHandInterpolator(),
FSGCoordinates::TransformToSenseGlove<FSGVect3DImpl::FVect3DType>(TotalGloveAngles)))
FSGAngles::TransformToSenseGlove<FSGVect3DImpl::FVect3DType>(TotalGloveAngles)))
};
return MoveTemp(Angles);
}
@@ -112,7 +112,7 @@ TArray<FVector> FSGHandInterpolatorImpl::InterpolateThumbAngles(const FSGHandInt
FSGArrayUtils::FromSenseGloveAngles<FSGVect3DImpl::FVect3DType>(
FHandInterpolatorType::InterpolateThumbAngles(
Interpolator.ToHandInterpolator(),
FSGCoordinates::TransformToSenseGlove<FSGVect3DImpl::FVect3DType>(TotalGloveAngles)))
FSGAngles::TransformToSenseGlove<FSGVect3DImpl::FVect3DType>(TotalGloveAngles)))
};
return MoveTemp(Angles);
}
@@ -199,7 +199,7 @@ FSGHandInterpolatorImpl::FSGHandInterpolatorImpl(FSGHandInterpolatorImpl&& Rhs)
#if SG_CPP17
noexcept
#endif /* SG_CPP17 */
= default;
= default;
FSGHandInterpolatorImpl::~FSGHandInterpolatorImpl() = default;
@@ -238,14 +238,14 @@ FQuat FSGHandInterpolatorImpl::GetCmcStartRotation() const
float FSGHandInterpolatorImpl::CalculateAngle(const ESGFinger Finger, const int32 Movement, const float Value) const
{
return FSGCoordinates::TransformToUnreal(
return FSGAngles::TransformToUnreal(
Movement, Pimpl->HandInterpolator.CalculateAngle(FSGCoreEnumCast::ToEFinger(Finger), Movement, Value));
}
float FSGHandInterpolatorImpl::CalculateAngle(const ESGFinger Finger, const ESGFingerMovement Movement,
const float Value) const
{
return FSGCoordinates::TransformToUnreal(
return FSGAngles::TransformToUnreal(
Movement, Pimpl->HandInterpolator.CalculateAngle(FSGCoreEnumCast::ToEFinger(Finger),
FSGCoreEnumCast::ToEFingerMovement(Movement), Value));
}
@@ -253,7 +253,7 @@ float FSGHandInterpolatorImpl::CalculateAngle(const ESGFinger Finger, const ESGF
float FSGHandInterpolatorImpl::CalculateAngle(const ESGFinger Finger, const ESGThumbMovement Movement,
const float Value) const
{
return FSGCoordinates::TransformToUnreal(
return FSGAngles::TransformToUnreal(
Movement, Pimpl->HandInterpolator.CalculateAngle(FSGCoreEnumCast::ToEFinger(Finger),
FSGCoreEnumCast::ToEThumbMovement(Movement), Value));
}
@@ -263,8 +263,8 @@ void FSGHandInterpolatorImpl::SetInterpolation(
const float InputAt0, const float InputAt1, const float AngleAt0, const float AngleAt1)
{
Pimpl->HandInterpolator.SetInterpolation(Finger, Movement, InputAt0, InputAt1,
FSGCoordinates::TransformToUnreal(Movement, AngleAt0),
FSGCoordinates::TransformToUnreal(Movement, AngleAt1));
FSGAngles::TransformToUnreal(Movement, AngleAt0),
FSGAngles::TransformToUnreal(Movement, AngleAt1));
}
void FSGHandInterpolatorImpl::SetInterpolation(
@@ -274,8 +274,8 @@ void FSGHandInterpolatorImpl::SetInterpolation(
Pimpl->HandInterpolator.SetInterpolation(
FSGCoreEnumCast::ToEFinger(Finger), FSGCoreEnumCast::ToEFingerMovement(Movement),
InputAt0, InputAt1,
FSGCoordinates::TransformToUnreal(Movement, AngleAt0),
FSGCoordinates::TransformToUnreal(Movement, AngleAt1));
FSGAngles::TransformToUnreal(Movement, AngleAt0),
FSGAngles::TransformToUnreal(Movement, AngleAt1));
}
void FSGHandInterpolatorImpl::SetInterpolation(
@@ -284,8 +284,8 @@ void FSGHandInterpolatorImpl::SetInterpolation(
{
Pimpl->HandInterpolator.SetInterpolation(FSGCoreEnumCast::ToEThumbMovement(Movement),
InputAt0, InputAt1,
FSGCoordinates::TransformToUnreal(Movement, AngleAt0),
FSGCoordinates::TransformToUnreal(Movement, AngleAt1));
FSGAngles::TransformToUnreal(Movement, AngleAt0),
FSGAngles::TransformToUnreal(Movement, AngleAt1));
}
FSGInterpolationSetImpl FSGHandInterpolatorImpl::GetInterpolation(const int32 Finger, const int32 Movement) const
@@ -314,4 +314,4 @@ FSGHandInterpolatorImpl::FImpl::~FImpl() = default;
void FSGHandInterpolatorImpl::FImplDeleter::operator()(const FImpl* P) const
{
delete P;
}
}
@@ -47,8 +47,8 @@
#include "SGCoreImpl/SGCoreEnumCast.h"
#include "SGCoreImpl/SGQuatImpl.h"
#include "SGCoreImpl/SGVect3DImpl.h"
#include "SGUtils/SGAngles.h"
#include "SGUtils/SGArrayUtils.h"
#include "SGUtils/SGCoordinates.h"
struct FSGHandPoseImpl::FImpl
{
@@ -45,8 +45,8 @@
#include "SGCoreImpl/SGCoreEnumCast.h"
#include "SGCoreImpl/SGSensorRangeImpl.h"
#include "SGCoreImpl/SGVect3DImpl.h"
#include "SGUtils/SGAngles.h"
#include "SGUtils/SGArrayUtils.h"
#include "SGUtils/SGCoordinates.h"
struct FSGHapticGloveCalibrationCheckImpl::FImpl
{
@@ -103,7 +103,7 @@ float FSGHapticGloveCalibrationCheckImpl::GetSenseGloveMinAbduction()
{
/// TODO
/// Maybe use enums?
return FSGCoordinates::TransformToUnreal(2, FHapticGloveCalibrationCheckType::GetSenseGloveMinAbduction());
return FSGAngles::TransformToUnreal(2, FHapticGloveCalibrationCheckType::GetSenseGloveMinAbduction());
}
float FSGHapticGloveCalibrationCheckImpl::GetNovaGloveMinAbduction()
@@ -33,4 +33,4 @@
*/
#include "SGUtils/SGCoordinates.h"
#include "SGUtils/SGAngles.h"
@@ -39,24 +39,24 @@
#include "SGTypes/SGCoreTypes.h"
class SENSEGLOVEUTILS_API FSGCoordinates final
class SENSEGLOVEUTILS_API FSGAngles final
{
public:
static FORCEINLINE constexpr float TransformToSenseGlove(const int32 Movement, const float Direction)
{
// 0 = twist, 1 = flexion/extension, 2 = abduction
return Movement != 1 ? Direction * -1.0f : Direction;
return FMath::DegreesToRadians(Movement != 1 ? Direction * -1.0f : Direction);
}
static FORCEINLINE FVector TransformToSenseGlove(const FVector& Vector)
{
return FVector(Vector.X * -1.0f, Vector.Y, Vector.Z * -1.0f);
return FMath::DegreesToRadians(FVector(Vector.X * -1.0f, Vector.Z, Vector.Y));
}
template<typename V>
static FORCEINLINE V TransformToSenseGlove(const FVector& Vector)
{
return V(Vector.X * -1.0f, Vector.Y, Vector.Z * -1.0f);
return FMath::DegreesToRadians(V(Vector.X * -1.0f, Vector.Z, Vector.Y));
}
static FORCEINLINE constexpr float TransformToUnreal(const int32 Movement, const float Direction)
@@ -94,24 +94,26 @@ public:
// 0 = twist, 1 = flexion/extension, 2 = abduction
/// TODO
/// Which flexions should be ignored?
return (Movement != ESGThumbMovement::CmcFlexion && Movement != ESGThumbMovement::McpFlexion && Movement !=
ESGThumbMovement::IpFlexion)
return FMath::RadiansToDegrees(
Movement != ESGThumbMovement::CmcFlexion
&& Movement != ESGThumbMovement::McpFlexion
&& Movement != ESGThumbMovement::IpFlexion
? Direction * -1.0f
: Direction;
: Direction);
}
static FORCEINLINE FVector TransformToUnreal(const FVector& Vector)
{
return FVector(Vector.X * -1.0f, Vector.Y, Vector.Z * -1.0f);
return FMath::RadiansToDegrees(FVector(Vector.X * -1.0f, Vector.Z, Vector.Y));
}
template<typename V>
static FORCEINLINE FVector TransformToUnreal(const V& Vector)
{
return FVector(Vector.GetX() * -1.0f, Vector.GetY(), Vector.GetZ() * -1.0f);
return FMath::RadiansToDegrees(FVector(Vector.GetX() * -1.0f, Vector.GetZ(), Vector.GetY()));
}
public:
FSGCoordinates() = delete;
virtual ~FSGCoordinates() = delete;
FSGAngles() = delete;
virtual ~FSGAngles() = delete;
};
@@ -37,7 +37,7 @@
#include <vector>
#include "SGCoordinates.h"
#include "SGAngles.h"
#include "Containers/Array.h"
#include "Templates/UnrealTemplate.h"
@@ -617,7 +617,7 @@ public:
for (const FVector& Value: Array)
{
Vector.emplace_back(FSGCoordinates::TransformToSenseGlove<V3D>(Value));
Vector.emplace_back(FSGAngles::TransformToSenseGlove<V3D>(Value));
}
return MoveTemp(Vector);
@@ -644,7 +644,7 @@ public:
for (const V3D& Value: Vector)
{
Array.Add(FSGCoordinates::TransformToUnreal<V3D>(Value));
Array.Add(FSGAngles::TransformToUnreal<V3D>(Value));
}
return MoveTemp(Array);