demotool/utilities.cc

41 lines
1,023 B
C++

#include "externals.hh"
#include "utilities.hh"
void disableButton( )
{
ImGui::PushStyleColor( ImGuiCol_Button , ImVec4( .3 , .3 , .3 , 1 ) );
ImGui::PushStyleColor( ImGuiCol_ButtonHovered , ImVec4( .3 , .3 , .3 , 1 ) );
ImGui::PushStyleColor( ImGuiCol_ButtonActive , ImVec4( .3 , .3 , .3 , 1 ) );
}
/*----------------------------------------------------------------------------*/
void updateAngle(
__rw__ float& initial ,
__rd__ const float delta
)
{
initial = fmod( initial + delta + 540 , 360 ) - 180;
}
void anglesToMatrix(
__rd__ float const* angles ,
__wr__ 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];
}