62 lines
1.2 KiB
C++
62 lines
1.2 KiB
C++
#include "externals.hh"
|
|
#include "utilities.hh"
|
|
|
|
|
|
void updateAngle(
|
|
float& initial ,
|
|
const float delta
|
|
)
|
|
{
|
|
initial = fmod( initial + delta + 540 , 360 ) - 180;
|
|
}
|
|
|
|
void anglesToMatrix(
|
|
float const* angles ,
|
|
float* matrix )
|
|
{
|
|
float c[3] , s[3];
|
|
for ( int i = 0 ; i < 3 ; i ++ ) {
|
|
const float a = M_PI * angles[ i ] / 180;
|
|
c[i] = cos( a );
|
|
s[i] = sin( a );
|
|
}
|
|
matrix[0] = c[1]*c[2];
|
|
matrix[1] = s[0]*s[1]*c[2] - c[0]*s[2];
|
|
matrix[2] = s[0]*s[2] + c[0]*s[1]*c[2];
|
|
matrix[3] = c[1]*s[2];
|
|
matrix[4] = c[0]*c[2] + s[0]*s[1]*s[2];
|
|
matrix[5] = c[0]*s[1]*s[2] - s[0]*c[2];
|
|
matrix[6] = -s[1];
|
|
matrix[7] = s[0]*c[1];
|
|
matrix[8] = c[0]*c[1];
|
|
}
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
T_String GetAbsolutePath(
|
|
T_String const& path )
|
|
{
|
|
char* const rp( realpath( (char*) path.toOSString( ).data( ) , nullptr ) );
|
|
if ( !rp ) {
|
|
return {};
|
|
}
|
|
|
|
const T_String rv( rp );
|
|
free( rp );
|
|
return rv;
|
|
}
|
|
|
|
T_String GetParentPath(
|
|
T_String const& path )
|
|
{
|
|
auto buffer( path.toOSString( ) );
|
|
|
|
char* const rp( realpath( dirname( (char*) buffer.data( ) ) , nullptr ) );
|
|
if ( !rp ) {
|
|
return {};
|
|
}
|
|
|
|
const T_String rv( rp );
|
|
free( rp );
|
|
return rv;
|
|
}
|