demotool/c-utilities.hh
2017-11-23 23:31:24 +01:00

53 lines
1.3 KiB
C++

#pragma once
#ifndef REAL_BUILD
# include "externals.hh"
#endif
/*= Utilities ================================================================*/
// Add some value to an angle, keeping it in [-180;180]
void updateAngle(
float& initial ,
const float delta
);
// Make a rotation matrix from three YPR angles (in degrees)
void anglesToMatrix(
float const* angles ,
float* matrix );
/*----------------------------------------------------------------------------*/
// Helpers for finding entries in collections
template< typename T , typename I >
inline auto find(
T const& collection ,
I const& item )
{
return std::find( collection.begin( ) , collection.end( ) , item );
}
template< typename T , typename I >
inline auto find(
T& collection ,
I const& item )
{
return std::find( collection.begin( ) , collection.end( ) , item );
}
template< typename T , typename I >
inline bool Contains(
T const& collection ,
I const& item )
{
return std::find( collection.begin( ) , collection.end( ) , item ) != collection.end( );
}
/*----------------------------------------------------------------------------*/
// Get the absolute path
std::string GetAbsolutePath(
std::string const& path );
// Get the absolute parent path for a (possibly relative) path
std::string GetParentPath(
std::string const& path );