← All articles

That new code smell – with a C# example

The High Performance Game Development article is coming along fine. I wrote up some C# code that follows with the article, most of the code consists of examples of transcendental function approximations.

Here is a pretty example of a sine function using Taylor Series. This seventh-degree polynomial takes radians and is most accurate near zero; accuracy deteriorates as the input moves farther from zero:

C#
public static float FastSin(float x)
{
    return x - ((x * x * x) / 6) + ((x * x * x * x * x) / 120) - ((x * x * x * x * x * x * x) / 5040);
}

Much more to come!

More in Algorithms

All 25 Algorithms articles →