OSVR-Core
Classes | Macros | Typedefs | Functions
QuatExpMap.cpp File Reference

Implementation. More...

#include <osvr/Util/EigenQuatExponentialMap.h>
#include "../EigenTestHelpers.h"
#include "quat.h"
#include "gtest/gtest.h"
#include <array>

Classes

class  QuatCreator
 
class  UnitQuatInput
 
class  ExpMapVecInput
 
class  EquivalentInput
 

Macros

#define OSVR_CAN_USE_PARAMETERIZED_TESTS
 

Typedefs

using quat_array::array_type = std::array< double, 4 >
 
using QuatVecPair = std::pair< QuatCreator, Eigen::Vector3d >
 

Functions

void quat_array::set (array_type &arr, Eigen::Quaterniond const &quat)
 
array_type quat_array::set (Eigen::Quaterniond const &quat)
 
void quat_array::get (Eigen::Quaterniond &quat, array_type const &arr)
 
Eigen::Quaterniond quat_array::get (array_type const &arr)
 
std::string formatAngleAxis (double angle, Eigen::Vector3d const &axis)
 
inline ::std::ostream & operator<< (::std::ostream &os, QuatCreator const &q)
 
QuatVecPair makePairFromAngleAxis (double angle, Eigen::Vector3d const &axis)
 
inline ::std::ostream & operator<< (::std::ostream &os, QuatVecPair const &q)
 
 TEST_P (UnitQuatInput, BasicRunLn)
 
 TEST_P (UnitQuatInput, RoundTripLn)
 
 TEST_P (UnitQuatInput, QuatlibRoundTripLn)
 
 INSTANTIATE_TEST_CASE_P (BasicQuats, UnitQuatInput, ::testing::Values(QuatCreator::Identity(), QuatCreator::AngleAxis(M_PI/2, Vector3d::UnitX()), QuatCreator::AngleAxis(M_PI/2, Vector3d::UnitY()), QuatCreator::AngleAxis(M_PI/2, Vector3d::UnitZ()), QuatCreator::AngleAxis(-M_PI/2, Vector3d::UnitX()), QuatCreator::AngleAxis(-M_PI/2, Vector3d::UnitY()), QuatCreator::AngleAxis(-M_PI/2, Vector3d::UnitZ())))
 
 INSTANTIATE_TEST_CASE_P (SmallQuats, UnitQuatInput, ::testing::Values(QuatCreator::AngleAxis(SMALL, Vector3d::UnitX()), QuatCreator::AngleAxis(SMALL, Vector3d::UnitY()), QuatCreator::AngleAxis(SMALL, Vector3d::UnitZ()), QuatCreator::AngleAxis(SMALLER, Vector3d::UnitX()), QuatCreator::AngleAxis(SMALLER, Vector3d::UnitY()), QuatCreator::AngleAxis(SMALLER, Vector3d::UnitZ())))
 
 INSTANTIATE_TEST_CASE_P (SmallNegativeQuats, UnitQuatInput, ::testing::Values(QuatCreator::AngleAxis(-SMALL, Vector3d::UnitX()), QuatCreator::AngleAxis(-SMALL, Vector3d::UnitY()), QuatCreator::AngleAxis(-SMALL, Vector3d::UnitZ()), QuatCreator::AngleAxis(-SMALLER, Vector3d::UnitX()), QuatCreator::AngleAxis(-SMALLER, Vector3d::UnitY()), QuatCreator::AngleAxis(-SMALLER, Vector3d::UnitZ())))
 
 TEST_P (ExpMapVecInput, BasicRunExp)
 
 TEST_P (ExpMapVecInput, RoundTripExp)
 
 TEST_P (ExpMapVecInput, QuatlibRoundTripExp)
 
 INSTANTIATE_TEST_CASE_P (BasicVecs, ExpMapVecInput, ::testing::Values(Vector3d::Zero(), Vector3d(M_PI/2, 0, 0), Vector3d(0, M_PI/2, 0), Vector3d(0, 0, M_PI/2), Vector3d(-M_PI/2, 0, 0), Vector3d(0, -M_PI/2, 0), Vector3d(0, 0, -M_PI/2)))
 
 INSTANTIATE_TEST_CASE_P (SmallVecs, ExpMapVecInput, ::testing::Values(Vector3d(SMALL, 0, 0), Vector3d(0, SMALL, 0), Vector3d(0, 0, SMALL), Vector3d(SMALLER, 0, 0), Vector3d(0, SMALLER, 0), Vector3d(0, 0, SMALLER)))
 
 INSTANTIATE_TEST_CASE_P (SmallNegativeVecs, ExpMapVecInput, ::testing::Values(Vector3d(-SMALL, 0, 0), Vector3d(0, -SMALL, 0), Vector3d(0, 0, -SMALL), Vector3d(-SMALLER, 0, 0), Vector3d(0, -SMALLER, 0), Vector3d(0, 0, -SMALLER)))
 
Quaterniond makeQuat (double angle, Vector3d const &axis)
 
 TEST (SimpleEquivalencies, Ln)
 
 TEST (SimpleEquivalencies, Exp)
 
 TEST_P (EquivalentInput, DISABLED_Ln)
 
 TEST_P (EquivalentInput, LnCompareWithQuatlib)
 
 TEST_P (EquivalentInput, DISABLED_Exp)
 
 TEST_P (EquivalentInput, ExpCompareWithQuatlib)
 
 INSTANTIATE_TEST_CASE_P (HalfPiMultiples, EquivalentInput, ::testing::Values(makePairFromAngleAxis(M_PI/2, Vector3d::UnitX()), makePairFromAngleAxis(M_PI/2, Vector3d::UnitY()), makePairFromAngleAxis(M_PI/2, Vector3d::UnitZ()), makePairFromAngleAxis(-M_PI/2, Vector3d::UnitX()), makePairFromAngleAxis(-M_PI/2, Vector3d::UnitY()), makePairFromAngleAxis(-M_PI/2, Vector3d::UnitZ())))
 
 INSTANTIATE_TEST_CASE_P (SmallValues, EquivalentInput, ::testing::Values(makePairFromAngleAxis(SMALL, Vector3d::UnitX()), makePairFromAngleAxis(SMALL, Vector3d::UnitY()), makePairFromAngleAxis(SMALL, Vector3d::UnitZ()), makePairFromAngleAxis(SMALLER, Vector3d::UnitX()), makePairFromAngleAxis(SMALLER, Vector3d::UnitY()), makePairFromAngleAxis(SMALLER, Vector3d::UnitZ())))
 
 INSTANTIATE_TEST_CASE_P (SmallNegativeValues, EquivalentInput, ::testing::Values(makePairFromAngleAxis(-SMALL, Vector3d::UnitX()), makePairFromAngleAxis(-SMALL, Vector3d::UnitY()), makePairFromAngleAxis(-SMALL, Vector3d::UnitZ()), makePairFromAngleAxis(-SMALLER, Vector3d::UnitX()), makePairFromAngleAxis(-SMALLER, Vector3d::UnitY()), makePairFromAngleAxis(-SMALLER, Vector3d::UnitZ())))
 

Quatlib interaction utilities

Container for q_type that's C++-safe to pass around and such.

To pass to quatlib functions, use the .data() member function.

using QuatlibQuatArray = std::array< double, 4 >
 
QuatlibQuatArray toQuatlib (Vector3d const &vec)
 Convert Eigen vector to a quatlib (pure: w = 0) quaternion, wrapped in an std::array. More...
 
QuatlibQuatArray toQuatlib (Quaterniond const &q)
 Convert Eigen quat to a quatlib quaternion, wrapped in an std::array.
 
Quaterniond quatFromQuatlib (QuatlibQuatArray const &arr)
 Takes a quatlib quaternion wrapped in an array and converts it to an Eigen::Quaterniond, no questions asked. More...
 
Vector3d vecFromQuatlib (QuatlibQuatArray const &arr)
 Takes a quatlib quaternion wrapped in an array and converts it to an Eigen::Vector3d, no questions asked - assumes it's a pure quaternion (w=0) or that you just want the vector part. More...
 

Detailed Description

Implementation.

Date
2016
Author
Sensics, Inc. http://sensics.com/osvr

Macro Definition Documentation

§ OSVR_CAN_USE_PARAMETERIZED_TESTS

#define OSVR_CAN_USE_PARAMETERIZED_TESTS
Todo:
These cause link failures in Windows/DLL debug builds.

For now, just assume they're tested enough in release mode.

Function Documentation

§ quatFromQuatlib()

Quaterniond quatFromQuatlib ( QuatlibQuatArray const &  arr)
inline

Takes a quatlib quaternion wrapped in an array and converts it to an Eigen::Quaterniond, no questions asked.

§ TEST_P() [1/2]

TEST_P ( EquivalentInput  ,
DISABLED_Ln   
)
Todo:
Test appears broken?

§ TEST_P() [2/2]

TEST_P ( EquivalentInput  ,
DISABLED_Exp   
)
Todo:
Test appears broken?

§ toQuatlib()

QuatlibQuatArray toQuatlib ( Vector3d const &  vec)
inline

Convert Eigen vector to a quatlib (pure: w = 0) quaternion, wrapped in an std::array.

§ vecFromQuatlib()

Vector3d vecFromQuatlib ( QuatlibQuatArray const &  arr)
inline

Takes a quatlib quaternion wrapped in an array and converts it to an Eigen::Vector3d, no questions asked - assumes it's a pure quaternion (w=0) or that you just want the vector part.