1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// 언리얼 엔진 코드에서 가져옴. 지정된 각도에 대한 두 삼각함수를 함께 가져오는 함수. 
    static FORCEINLINE constexpr void GetSinCosRad(float& OutSin, float& OutCos, float InRadian)
    {
        // Copied from UE4 Source Code
        // Map Value to y in [-pi,pi], x = 2*pi*quotient + remainder.
        float quotient = (InvPI * 0.5f) * InRadian;
        if (InRadian >= 0.0f)
        {
            quotient = (float)((int)(quotient + 0.5f));
        }
        else
        {
            quotient = (float)((int)(quotient - 0.5f));
        }
        float y = InRadian - (2.0f * PI) * quotient;
 
        // Map y to [-pi/2,pi/2] with sin(y) = sin(Value).
        float sign = 0.f;
        if (y > HalfPI)
        {
            y = PI - y;
            sign = -1.0f;
        }
        else if (y < -HalfPI)
        {
            y = -PI - y;
            sign = -1.0f;
        }
        else
        {
            sign = +1.0f;
        }
 
        float y2 = y * y;
 
        // 11-degree minimax approximation
        OutSin = (((((-2.3889859e-08f * y2 + 2.7525562e-06f) * y2 - 0.00019840874f) * y2 + 0.0083333310f) * y2 - 0.16666667f) * y2 + 1.0f) * y;
 
        // 10-degree minimax approximation
        float p = ((((-2.6051615e-07f * y2 + 2.4760495e-05f) * y2 - 0.0013888378f) * y2 + 0.041666638f) * y2 - 0.5f) * y2 + 1.0f;
        OutCos = sign * p;
    }
cs


이거 뭔소린지 이해가안갔는데 전체코드를보니까


1
2
3
4
void mysincos(float& OutSin, float& OutCos, float InRadian) {
    OutSin = sin(InRadian);
    OutCos = cos(InRadian);
}
cs


그냥 이렇게 적용이 되더라고요 위방식으로하는 이유가 따로있어? 연산이 엄청나게 빨라지나