sin(x + y) = sin(x) * cos(y) + cos(x) * sin(y) sin(x - y) = sin(x) * cos(y) - cos(x) * sin(y) cos(x + y) = cos(x) * cos(y) - sin(x) * sin(y) cos(x - y) = cos(x) * cos(y) + sin(x) * sin(y) tan(x + y) = (tan(x) + tan(y)) / (1 - tan(x) * tan(y)) tan(x - y) = (tan(x) - tan(y)) / (1 + tan(x) * tan(y))
sin(2 * x) = 2 * sin(x) * cos(x) cos(2 * x) = cos²(x) - sin²(x) = 2 * cos²(x) - 1 = 1 - 2 * sin²(x) tan(2 * x) = (2 * tan(x)) / (1 - tan²(x))
sin²(x / 2) = (1 - cos(x)) / 2 cos²(x / 2) = (1 + cos(x)) / 2 tan²(x / 2) = (1 - cos(x)) / (1 + cos(x))
sin(-θ)=-sinθ, cos(-θ)=cosθ, tan(-θ)=-tanθ sin²θ+cos²θ=1, sec²θ-tan²θ=1, csc²θ-cot²θ=1 sin(π/2-θ)=cosθ, sin(π/2+θ)=cosθ, sin(θ±π/2)=±cosθ cos(π/2-θ)=sinθ, cos(π/2+θ)=-sinθ, cos(θ±π/2)=Ŧsinθ sin(π-θ)=sinθ, sin(π+θ)=-sinθ, sin(θ±π)=-sinθ cos(π-θ)=-cosθ, cos(π+θ)=-cosθ, cos(θ±π)=-cosθ sin(α±β)=sinαcosβ±cosαsinβ, cos(α±β)=cosαcosβŦsinαsinβ tan(α+β)=tanα+tanβ/1-tanαtanβ, tan(α-β)=tanα-tanβ/1+tanαtanβ sin2θ=2sinθcosθ cos2θ=cos²θ-sin²θ=2cos²θ-1=1-2sin²θ, tan2θ=2tanθ/1-tan²θ sin²θ/2=1-cosθ/2, cos²θ/2=1+cosθ/2, tan²θ/2=1-cosθ/1+cosθ sinαcosβ=1/2{sin(α+β)+sin(α-β)} cosαcosβ=1/2{cos(α+β)+cos(α-β)} sinαsinβ=-1/2{cos(α+β)-cos(α-β)} sinα+sinβ=2sin(α+β/2)cos(α-β/2) sinα-sinβ=2cos(α+β/2)sin(α-β/2) cosα+cosβ=2cos(α+β/2)cos(α-β/2) cosα-cosβ=-2sin(α+β/2)sin(α-β/2)
/*--------------------------------------------------------------------------*/ /* Purpose: sin, cos */ /*--------------------------------------------------------------------------*/ #define twoopi 0.636619772367581 #define p0 0.135788409787738e8 #define p1 -0.494290810090284e7 #define p2 0.440103053537527e6 #define p3 -0.138472724998245e5 #define p4 0.145968840666577e3 #define q0 0.864455865292253e7 #define q1 0.408179225234330e6 #define q2 0.946309610153821e4 #define q3 0.132653490878614e3 static double sinus(double arg, int quad) { double e, f; int k; double ysq; double x, y; double temp1, temp2; x = arg; if (x < 0) { x = -x; quad = quad + 2; } x = x * twoopi; /*underflow?*/ if (x > 32764) { y = modf(x,&e); e = e + quad; modf(0.25*e,&f); quad = e - 4*f; } else{ k = x; y = x - k; quad = (quad + k) & 03; } if (quad & 01) y = 1-y; if (quad > 1) y = -y; ysq = y*y; temp1 = ((((p4*ysq+p3)*ysq+p2)*ysq+p1)*ysq+p0)*y; temp2 = ((((ysq+q3)*ysq+q2)*ysq+q1)*ysq+q0); return(temp1/temp2); } /* cos() 함수는 x의 코사인 값(라디안 값)을 계산합니다. */ double cos(double x) { if (x < 0.0) x = -x; return (sinus(x, 1)); } /* sin() 함수는 x의 사인 값(라디안 값)을 계산합니다. */ double sin(double x) { return (sinus(x, 0)); } /* ### 주의 사항 ### 위의 sinus 함수에서 사용한 modf 함수는 주어진 수를 정수부분과 소수부분으로 나누어 주는 함수입니다. 예를 들어서 y = modf(x,&e); 라고 하면 x의 정수부분이 e 변수에 들어가고 소수부분이 y 변수에 들어가게 됩니다. */
//범위는 -PI ~ PI 로 둡니다. double Sine(double x) { double sum = x; double result = x; double fact = 1.0f; double x2 = x*x*-1.0f;; //유한한 테일러 급수 전개 for(int i=1;i<9;++i) { fact *= ((2*i) * (2*i+1)); result *= x2; sum += (result / fact); } return sum; }
Copyrights © - Joinc, All Rights Reserved. Inherited From - Yundream Rebranded By - Joonphil
설명
사용방법
코드
변경사항
2005/08/23
Recent Posts
Archive Posts
Tags