176 lines
4.3 KiB
C++
176 lines
4.3 KiB
C++
/**
|
|
* @file
|
|
*
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @section LICENSE
|
|
*
|
|
* (The MIT License)
|
|
*
|
|
* Copyright (c) 2020 - 2023 SenseGlove
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*
|
|
* @section DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "Containers/UnrealString.h"
|
|
#include "Math/Quat.h"
|
|
#include "Math/Vector.h"
|
|
#include "Runtime/Launch/Resources/Version.h"
|
|
#include "Templates/UniquePtr.h"
|
|
|
|
#include "SGCoreImpl/SGPlatform.h"
|
|
|
|
class FSGVect3DImpl;
|
|
|
|
namespace SGCore
|
|
{
|
|
namespace Kinematics
|
|
{
|
|
class Quat;
|
|
}
|
|
}
|
|
|
|
class SENSEGLOVECOREIMPL_API FSGQuatImpl
|
|
{
|
|
public:
|
|
typedef SGCore::Kinematics::Quat FQuatType;
|
|
|
|
public:
|
|
static const FSGQuatImpl& Identity();
|
|
|
|
static FSGQuatImpl FromEuler(float XAngle, float YAngle, float ZAngle);
|
|
static FSGQuatImpl FromEuler(const FSGVect3DImpl& Euler);
|
|
static FSGQuatImpl FromEuler(const FVector& Euler);
|
|
static FSGQuatImpl FromAngleAxis(float Angle, float XAxis, float YAxis, float ZAxis);
|
|
static FSGQuatImpl FromAngleAxis(float Angle, const FSGVect3DImpl& Axis);
|
|
static FSGQuatImpl FromAngleAxis(float Angle, const FVector& Axis);
|
|
|
|
static FSGQuatImpl Invert(const FSGQuatImpl& QuatImpl);
|
|
static FSGQuatImpl Normalize(const FSGQuatImpl& QuatImpl);
|
|
|
|
static bool Deserialize(const FString& String, FSGQuatImpl& OutResult, ANSICHAR Delimiter);
|
|
|
|
private:
|
|
struct FImpl;
|
|
|
|
struct FImplDeleter
|
|
{
|
|
void operator()(const FImpl* P) const;
|
|
};
|
|
|
|
TUniquePtr<FImpl, FImplDeleter> Pimpl;
|
|
FImplDeleter PimplDeleter;
|
|
|
|
public:
|
|
FSGQuatImpl();
|
|
FSGQuatImpl(float X, float Y, float Z, float W);
|
|
|
|
public:
|
|
/**
|
|
* The cast from underlying type constructor.
|
|
*/
|
|
explicit FSGQuatImpl(const FQuatType& Quat);
|
|
|
|
/**
|
|
* The cast from FQuat type constructor.
|
|
*/
|
|
explicit FSGQuatImpl(const FQuat& Quat);
|
|
|
|
public:
|
|
/**
|
|
* The copy constructor.
|
|
*/
|
|
FSGQuatImpl(const FSGQuatImpl& Rhs);
|
|
|
|
/**
|
|
* The move constructor.
|
|
*/
|
|
FSGQuatImpl(FSGQuatImpl&& Rhs) SG_NOEXCEPT;
|
|
|
|
public:
|
|
/**
|
|
* The destructor.
|
|
*/
|
|
virtual ~FSGQuatImpl();
|
|
|
|
public:
|
|
/**
|
|
* The copy assignment operator.
|
|
*/
|
|
FSGQuatImpl& operator=(const FSGQuatImpl& Rhs);
|
|
|
|
/**
|
|
* The move assignment operator.
|
|
*/
|
|
FSGQuatImpl& operator=(FSGQuatImpl&& Rhs) SG_NOEXCEPT;
|
|
|
|
public:
|
|
/**
|
|
* The cast to underlying type method.
|
|
*/
|
|
const FQuatType& ToQuat() const;
|
|
|
|
/**
|
|
* The cast to FQuat type method.
|
|
*/
|
|
FQuat ToFQuat() const;
|
|
|
|
public:
|
|
FSGQuatImpl operator*(const FSGQuatImpl& QuatImpl) const;
|
|
FSGVect3DImpl operator*(const FSGVect3DImpl& Vect3DImpl) const;
|
|
FVector operator*(const FVector& Vector) const;
|
|
|
|
public:
|
|
float GetX() const;
|
|
void SetX(float X);
|
|
|
|
float GetY() const;
|
|
void SetY(float Y);
|
|
|
|
float GetZ() const;
|
|
void SetZ(float Z);
|
|
|
|
float GetW() const;
|
|
void SetW(float W);
|
|
|
|
public:
|
|
FSGVect3DImpl ToEulerImpl() const;
|
|
FVector ToEuler() const;
|
|
|
|
FSGVect3DImpl Rotate(const FSGVect3DImpl& Vect3DImpl) const;
|
|
FVector Rotate(const FVector& Vector) const;
|
|
|
|
bool Equals(const FSGQuatImpl& QuatImpl) const;
|
|
|
|
bool IsIdentity() const;
|
|
|
|
float Magnitude() const;
|
|
|
|
FString ToString() const;
|
|
|
|
FString Serialize(ANSICHAR Delimiter) const;
|
|
};
|