Hi

I was thinking I might be able to provide some code to SFML ... possibly ...

.

It's this: There are sin() and cos() functions at least in 3 modules:

Transformable.hpp

rotate.hpp

view.hpp

And there something like this:

float angle = m_rotation * 3.141592654f / 180.f;

float cosine = static_cast<float>(std::cos(angle));

float sine = static_cast<float>(std::sin(angle));

sin() and cos() are significantly slower than multiplication and division so I was thinking if I could find an approximation function which gives the same result/accuracy as sin/cos but is faster. Now I finished working on that and my function fastSin(float angle) is more than 80% faster than std::sin() (and I can do the same for cos()). The good thing is that it is basically as accurate as std::sin(). So calling for example std::sin(0.2866) and fastSin(0.2866) gives the same result, it is just > 80% faster (so about 2 times faster).

(actually in testing it was 82% -340% faster depending on how many sin() calls in a row).

I know this is not super critical, as those functions with sin/cos (like the getTransform()) are not likely to be called hundreds of thousands of times per second. But if this is any useful I am ready to provide the code for it.

By the way, I studied mathematics in an university and actually my final thesis was just about this: approximating functions (like sin()) by polynomial functions.

Any thoughts?