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:
@@ -38,8 +38,8 @@
|
|||||||
#include "SGBuildHacks/SGInclude_Core_Anatomy.h"
|
#include "SGBuildHacks/SGInclude_Core_Anatomy.h"
|
||||||
#include "SGBuildHacks/SGInclude_Core_Vect3D.h"
|
#include "SGBuildHacks/SGInclude_Core_Vect3D.h"
|
||||||
#include "SGCoreImpl/SGVect3DImpl.h"
|
#include "SGCoreImpl/SGVect3DImpl.h"
|
||||||
|
#include "SGUtils/SGAngles.h"
|
||||||
#include "SGUtils/SGArrayUtils.h"
|
#include "SGUtils/SGArrayUtils.h"
|
||||||
#include "SGUtils/SGCoordinates.h"
|
|
||||||
|
|
||||||
float FSGAnatomyImpl::GetTotalFingerFlexion()
|
float FSGAnatomyImpl::GetTotalFingerFlexion()
|
||||||
{
|
{
|
||||||
@@ -64,14 +64,14 @@ float FSGAnatomyImpl::GetTotalThumbExtension()
|
|||||||
float FSGAnatomyImpl::GetFingerJointLimit(
|
float FSGAnatomyImpl::GetFingerJointLimit(
|
||||||
const bool bRightHanded, const int32 Joint, const int32 Movement, const bool bMax)
|
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));
|
Movement, FAnatomyType::GetFingerJointLimit(bRightHanded, Joint, Movement, bMax));
|
||||||
}
|
}
|
||||||
|
|
||||||
float FSGAnatomyImpl::GetThumbJointLimit(
|
float FSGAnatomyImpl::GetThumbJointLimit(
|
||||||
const bool bRightHanded, const int32 Joint, const int32 Movement, const bool bMax)
|
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));
|
Movement, FAnatomyType::GetThumbJointLimit(bRightHanded, Joint, Movement, bMax));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,8 @@
|
|||||||
#include "SGCoreImpl/SGInterpolationSetImpl.h"
|
#include "SGCoreImpl/SGInterpolationSetImpl.h"
|
||||||
#include "SGCoreImpl/SGQuatImpl.h"
|
#include "SGCoreImpl/SGQuatImpl.h"
|
||||||
#include "SGCoreImpl/SGVect3DImpl.h"
|
#include "SGCoreImpl/SGVect3DImpl.h"
|
||||||
|
#include "SGUtils/SGAngles.h"
|
||||||
#include "SGUtils/SGArrayUtils.h"
|
#include "SGUtils/SGArrayUtils.h"
|
||||||
#include "SGUtils/SGCoordinates.h"
|
|
||||||
|
|
||||||
struct FSGHandInterpolatorImpl::FImpl
|
struct FSGHandInterpolatorImpl::FImpl
|
||||||
{
|
{
|
||||||
@@ -100,7 +100,7 @@ TArray<FVector> FSGHandInterpolatorImpl::InterpolateFingerAngles(
|
|||||||
FSGArrayUtils::FromSenseGloveAngles<FSGVect3DImpl::FVect3DType>(
|
FSGArrayUtils::FromSenseGloveAngles<FSGVect3DImpl::FVect3DType>(
|
||||||
FHandInterpolatorType::InterpolateFingerAngles(
|
FHandInterpolatorType::InterpolateFingerAngles(
|
||||||
FSGCoreEnumCast::ToEFinger(Finger), Interpolator.ToHandInterpolator(),
|
FSGCoreEnumCast::ToEFinger(Finger), Interpolator.ToHandInterpolator(),
|
||||||
FSGCoordinates::TransformToSenseGlove<FSGVect3DImpl::FVect3DType>(TotalGloveAngles)))
|
FSGAngles::TransformToSenseGlove<FSGVect3DImpl::FVect3DType>(TotalGloveAngles)))
|
||||||
};
|
};
|
||||||
return MoveTemp(Angles);
|
return MoveTemp(Angles);
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ TArray<FVector> FSGHandInterpolatorImpl::InterpolateThumbAngles(const FSGHandInt
|
|||||||
FSGArrayUtils::FromSenseGloveAngles<FSGVect3DImpl::FVect3DType>(
|
FSGArrayUtils::FromSenseGloveAngles<FSGVect3DImpl::FVect3DType>(
|
||||||
FHandInterpolatorType::InterpolateThumbAngles(
|
FHandInterpolatorType::InterpolateThumbAngles(
|
||||||
Interpolator.ToHandInterpolator(),
|
Interpolator.ToHandInterpolator(),
|
||||||
FSGCoordinates::TransformToSenseGlove<FSGVect3DImpl::FVect3DType>(TotalGloveAngles)))
|
FSGAngles::TransformToSenseGlove<FSGVect3DImpl::FVect3DType>(TotalGloveAngles)))
|
||||||
};
|
};
|
||||||
return MoveTemp(Angles);
|
return MoveTemp(Angles);
|
||||||
}
|
}
|
||||||
@@ -199,7 +199,7 @@ FSGHandInterpolatorImpl::FSGHandInterpolatorImpl(FSGHandInterpolatorImpl&& Rhs)
|
|||||||
#if SG_CPP17
|
#if SG_CPP17
|
||||||
noexcept
|
noexcept
|
||||||
#endif /* SG_CPP17 */
|
#endif /* SG_CPP17 */
|
||||||
= default;
|
= default;
|
||||||
|
|
||||||
FSGHandInterpolatorImpl::~FSGHandInterpolatorImpl() = 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
|
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));
|
Movement, Pimpl->HandInterpolator.CalculateAngle(FSGCoreEnumCast::ToEFinger(Finger), Movement, Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
float FSGHandInterpolatorImpl::CalculateAngle(const ESGFinger Finger, const ESGFingerMovement Movement,
|
float FSGHandInterpolatorImpl::CalculateAngle(const ESGFinger Finger, const ESGFingerMovement Movement,
|
||||||
const float Value) const
|
const float Value) const
|
||||||
{
|
{
|
||||||
return FSGCoordinates::TransformToUnreal(
|
return FSGAngles::TransformToUnreal(
|
||||||
Movement, Pimpl->HandInterpolator.CalculateAngle(FSGCoreEnumCast::ToEFinger(Finger),
|
Movement, Pimpl->HandInterpolator.CalculateAngle(FSGCoreEnumCast::ToEFinger(Finger),
|
||||||
FSGCoreEnumCast::ToEFingerMovement(Movement), Value));
|
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,
|
float FSGHandInterpolatorImpl::CalculateAngle(const ESGFinger Finger, const ESGThumbMovement Movement,
|
||||||
const float Value) const
|
const float Value) const
|
||||||
{
|
{
|
||||||
return FSGCoordinates::TransformToUnreal(
|
return FSGAngles::TransformToUnreal(
|
||||||
Movement, Pimpl->HandInterpolator.CalculateAngle(FSGCoreEnumCast::ToEFinger(Finger),
|
Movement, Pimpl->HandInterpolator.CalculateAngle(FSGCoreEnumCast::ToEFinger(Finger),
|
||||||
FSGCoreEnumCast::ToEThumbMovement(Movement), Value));
|
FSGCoreEnumCast::ToEThumbMovement(Movement), Value));
|
||||||
}
|
}
|
||||||
@@ -263,8 +263,8 @@ void FSGHandInterpolatorImpl::SetInterpolation(
|
|||||||
const float InputAt0, const float InputAt1, const float AngleAt0, const float AngleAt1)
|
const float InputAt0, const float InputAt1, const float AngleAt0, const float AngleAt1)
|
||||||
{
|
{
|
||||||
Pimpl->HandInterpolator.SetInterpolation(Finger, Movement, InputAt0, InputAt1,
|
Pimpl->HandInterpolator.SetInterpolation(Finger, Movement, InputAt0, InputAt1,
|
||||||
FSGCoordinates::TransformToUnreal(Movement, AngleAt0),
|
FSGAngles::TransformToUnreal(Movement, AngleAt0),
|
||||||
FSGCoordinates::TransformToUnreal(Movement, AngleAt1));
|
FSGAngles::TransformToUnreal(Movement, AngleAt1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSGHandInterpolatorImpl::SetInterpolation(
|
void FSGHandInterpolatorImpl::SetInterpolation(
|
||||||
@@ -274,8 +274,8 @@ void FSGHandInterpolatorImpl::SetInterpolation(
|
|||||||
Pimpl->HandInterpolator.SetInterpolation(
|
Pimpl->HandInterpolator.SetInterpolation(
|
||||||
FSGCoreEnumCast::ToEFinger(Finger), FSGCoreEnumCast::ToEFingerMovement(Movement),
|
FSGCoreEnumCast::ToEFinger(Finger), FSGCoreEnumCast::ToEFingerMovement(Movement),
|
||||||
InputAt0, InputAt1,
|
InputAt0, InputAt1,
|
||||||
FSGCoordinates::TransformToUnreal(Movement, AngleAt0),
|
FSGAngles::TransformToUnreal(Movement, AngleAt0),
|
||||||
FSGCoordinates::TransformToUnreal(Movement, AngleAt1));
|
FSGAngles::TransformToUnreal(Movement, AngleAt1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSGHandInterpolatorImpl::SetInterpolation(
|
void FSGHandInterpolatorImpl::SetInterpolation(
|
||||||
@@ -284,8 +284,8 @@ void FSGHandInterpolatorImpl::SetInterpolation(
|
|||||||
{
|
{
|
||||||
Pimpl->HandInterpolator.SetInterpolation(FSGCoreEnumCast::ToEThumbMovement(Movement),
|
Pimpl->HandInterpolator.SetInterpolation(FSGCoreEnumCast::ToEThumbMovement(Movement),
|
||||||
InputAt0, InputAt1,
|
InputAt0, InputAt1,
|
||||||
FSGCoordinates::TransformToUnreal(Movement, AngleAt0),
|
FSGAngles::TransformToUnreal(Movement, AngleAt0),
|
||||||
FSGCoordinates::TransformToUnreal(Movement, AngleAt1));
|
FSGAngles::TransformToUnreal(Movement, AngleAt1));
|
||||||
}
|
}
|
||||||
|
|
||||||
FSGInterpolationSetImpl FSGHandInterpolatorImpl::GetInterpolation(const int32 Finger, const int32 Movement) const
|
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
|
void FSGHandInterpolatorImpl::FImplDeleter::operator()(const FImpl* P) const
|
||||||
{
|
{
|
||||||
delete P;
|
delete P;
|
||||||
}
|
}
|
||||||
@@ -47,8 +47,8 @@
|
|||||||
#include "SGCoreImpl/SGCoreEnumCast.h"
|
#include "SGCoreImpl/SGCoreEnumCast.h"
|
||||||
#include "SGCoreImpl/SGQuatImpl.h"
|
#include "SGCoreImpl/SGQuatImpl.h"
|
||||||
#include "SGCoreImpl/SGVect3DImpl.h"
|
#include "SGCoreImpl/SGVect3DImpl.h"
|
||||||
|
#include "SGUtils/SGAngles.h"
|
||||||
#include "SGUtils/SGArrayUtils.h"
|
#include "SGUtils/SGArrayUtils.h"
|
||||||
#include "SGUtils/SGCoordinates.h"
|
|
||||||
|
|
||||||
struct FSGHandPoseImpl::FImpl
|
struct FSGHandPoseImpl::FImpl
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,8 +45,8 @@
|
|||||||
#include "SGCoreImpl/SGCoreEnumCast.h"
|
#include "SGCoreImpl/SGCoreEnumCast.h"
|
||||||
#include "SGCoreImpl/SGSensorRangeImpl.h"
|
#include "SGCoreImpl/SGSensorRangeImpl.h"
|
||||||
#include "SGCoreImpl/SGVect3DImpl.h"
|
#include "SGCoreImpl/SGVect3DImpl.h"
|
||||||
|
#include "SGUtils/SGAngles.h"
|
||||||
#include "SGUtils/SGArrayUtils.h"
|
#include "SGUtils/SGArrayUtils.h"
|
||||||
#include "SGUtils/SGCoordinates.h"
|
|
||||||
|
|
||||||
struct FSGHapticGloveCalibrationCheckImpl::FImpl
|
struct FSGHapticGloveCalibrationCheckImpl::FImpl
|
||||||
{
|
{
|
||||||
@@ -103,7 +103,7 @@ float FSGHapticGloveCalibrationCheckImpl::GetSenseGloveMinAbduction()
|
|||||||
{
|
{
|
||||||
/// TODO
|
/// TODO
|
||||||
/// Maybe use enums?
|
/// Maybe use enums?
|
||||||
return FSGCoordinates::TransformToUnreal(2, FHapticGloveCalibrationCheckType::GetSenseGloveMinAbduction());
|
return FSGAngles::TransformToUnreal(2, FHapticGloveCalibrationCheckType::GetSenseGloveMinAbduction());
|
||||||
}
|
}
|
||||||
|
|
||||||
float FSGHapticGloveCalibrationCheckImpl::GetNovaGloveMinAbduction()
|
float FSGHapticGloveCalibrationCheckImpl::GetNovaGloveMinAbduction()
|
||||||
|
|||||||
+1
-1
@@ -33,4 +33,4 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "SGUtils/SGCoordinates.h"
|
#include "SGUtils/SGAngles.h"
|
||||||
+13
-11
@@ -39,24 +39,24 @@
|
|||||||
|
|
||||||
#include "SGTypes/SGCoreTypes.h"
|
#include "SGTypes/SGCoreTypes.h"
|
||||||
|
|
||||||
class SENSEGLOVEUTILS_API FSGCoordinates final
|
class SENSEGLOVEUTILS_API FSGAngles final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
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
|
||||||
return Movement != 1 ? Direction * -1.0f : Direction;
|
return FMath::DegreesToRadians(Movement != 1 ? Direction * -1.0f : Direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCEINLINE FVector TransformToSenseGlove(const FVector& Vector)
|
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>
|
template<typename V>
|
||||||
static FORCEINLINE V TransformToSenseGlove(const FVector& Vector)
|
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)
|
static FORCEINLINE constexpr float TransformToUnreal(const int32 Movement, const float Direction)
|
||||||
@@ -94,24 +94,26 @@ public:
|
|||||||
// 0 = twist, 1 = flexion/extension, 2 = abduction
|
// 0 = twist, 1 = flexion/extension, 2 = abduction
|
||||||
/// TODO
|
/// TODO
|
||||||
/// Which flexions should be ignored?
|
/// Which flexions should be ignored?
|
||||||
return (Movement != ESGThumbMovement::CmcFlexion && Movement != ESGThumbMovement::McpFlexion && Movement !=
|
return FMath::RadiansToDegrees(
|
||||||
ESGThumbMovement::IpFlexion)
|
Movement != ESGThumbMovement::CmcFlexion
|
||||||
|
&& Movement != ESGThumbMovement::McpFlexion
|
||||||
|
&& Movement != ESGThumbMovement::IpFlexion
|
||||||
? Direction * -1.0f
|
? Direction * -1.0f
|
||||||
: Direction;
|
: Direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCEINLINE FVector TransformToUnreal(const FVector& Vector)
|
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>
|
template<typename V>
|
||||||
static FORCEINLINE FVector TransformToUnreal(const V& Vector)
|
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:
|
public:
|
||||||
FSGCoordinates() = delete;
|
FSGAngles() = delete;
|
||||||
virtual ~FSGCoordinates() = delete;
|
virtual ~FSGAngles() = delete;
|
||||||
};
|
};
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "SGCoordinates.h"
|
#include "SGAngles.h"
|
||||||
#include "Containers/Array.h"
|
#include "Containers/Array.h"
|
||||||
#include "Templates/UnrealTemplate.h"
|
#include "Templates/UnrealTemplate.h"
|
||||||
|
|
||||||
@@ -617,7 +617,7 @@ public:
|
|||||||
|
|
||||||
for (const FVector& Value: Array)
|
for (const FVector& Value: Array)
|
||||||
{
|
{
|
||||||
Vector.emplace_back(FSGCoordinates::TransformToSenseGlove<V3D>(Value));
|
Vector.emplace_back(FSGAngles::TransformToSenseGlove<V3D>(Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
return MoveTemp(Vector);
|
return MoveTemp(Vector);
|
||||||
@@ -644,7 +644,7 @@ public:
|
|||||||
|
|
||||||
for (const V3D& Value: Vector)
|
for (const V3D& Value: Vector)
|
||||||
{
|
{
|
||||||
Array.Add(FSGCoordinates::TransformToUnreal<V3D>(Value));
|
Array.Add(FSGAngles::TransformToUnreal<V3D>(Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
return MoveTemp(Array);
|
return MoveTemp(Array);
|
||||||
|
|||||||
Reference in New Issue
Block a user