demotool/c-utilities.hh

54 lines
1.3 KiB
C++
Raw Normal View History

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