for some reason I'm getting the following warning
filename.cpp:99:53: warning: narrowing conversion of ‘sin(((double)theta))’ from ‘double’ to ‘float’ inside { } [-Wnarrowing]
filename.cpp:99:66: warning: narrowing conversion of ‘cos(((double)theta))’ from ‘double’ to ‘float’ inside { } [-Wnarrowing]
which makes it sounds like it's trying to use the 'double cos(double)' etc. instead of 'float cos(float)' etc. I keep trying to think of more ways to suggest this to the compiler but am not getting anywhere. What can I do to resolve this?
void foo(float theta)
{
theta = (float)M_PI*theta/180.0f;
MyClass variable = { 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, cos(theta), -sin(theta), 0.0f,
0.0f, sin(theta), cos(theta), 0.0f,
0.0f, 0.0f, 0.0f, 1.0f };
bob = variable;
}
Thanks
Edit: changing it to this makes the warnings go away, but I'd still rather know what the problem is
float C = cos(theta), S = sin(theta);
MyClass variable = { 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, C, -S, 0.0f,
0.0f, S, C, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f };
sinf
andcosf
? – Tolidine