Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualbelfegor

Posted 26 April 2013 - 06:24 AM

+1 What kauna said.

 

Alternative fast sin/cos

 

float fast_sin(float rad)
{
    static const float B = 4 / D3DX_PI;
    static const float C = -4 / (D3DX_PI * D3DX_PI);

    float y = B * rad + C * rad * std::abs(rad);
    return y;
}

float fast_cos(float rad)
{
    static const float B = 4 / D3DX_PI;
    static const float C = -4 / (D3DX_PI * D3DX_PI);

    rad += 1.57079632f;
    float y = B * rad + C * rad * std::abs(rad);
    return y;
}

 

http://devmaster.net/forums/topic/4648-fast-and-accurate-sinecosine/

 

My code above is just an example, you could precalculate most stuff at init time, no need to do that every frame.


#2belfegor

Posted 26 April 2013 - 06:21 AM

+1 What kauna said.

 

Alternative fast sin/cos

 

float fast_sin(float rad)
{
    static const float B = 4 / D3DX_PI;
    static const float C = -4 / (D3DX_PI * D3DX_PI);

    float y = B * rad + C * rad * std::abs(rad);
    return y;
}

float fast_cos(float rad)
{
    static const float B = 4 / D3DX_PI;
    static const float C = -4 / (D3DX_PI * D3DX_PI);

    rad += 1.57079632f;
    float y = B * rad + C * rad * std::abs(rad);
    return y;
}

 

http://devmaster.net/forums/topic/4648-fast-and-accurate-sinecosine/


#1belfegor

Posted 26 April 2013 - 06:20 AM

Fast sin/cos

float fast_sin(float rad)
{
    static const float B = 4 / D3DX_PI;
    static const float C = -4 / (D3DX_PI * D3DX_PI);

    float y = B * rad + C * rad * std::abs(rad);
    return y;
}

float fast_cos(float rad)
{
    static const float B = 4 / D3DX_PI;
    static const float C = -4 / (D3DX_PI * D3DX_PI);

    rad += 1.57079632f;
    float y = B * rad + C * rad * std::abs(rad);
    return y;
}

 

http://devmaster.net/forums/topic/4648-fast-and-accurate-sinecosine/


PARTNERS