Sin 을 처리하는 함수를 유사하게 만들어봅니다.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace Ruru.Math
{
public class Sin
{
public static double GetSin(double x)
{
double sum = 0.0;
double r = 1.0;for (int i = 1; i < 13; i++)
{
r *= x / (1.0 * i);switch (i % 4)
{
case 1: sum += r; break; // 1
case 3: sum += (-1) * r; break; // -1
case 2:
case 4: break; // 0
}
}
return sum;
}public static void PrintSin()
{
for (int i = 0; i < 180; i++)
Console.WriteLine("Sin({0}) = {1}", i, GetSin(System.Math.PI*i/180.0));
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace Ruru.Math
{
class SinMain
{
static void Main(string[] args)
{
Sin.PrintSin();
}
}
}
'.NET > C#' 카테고리의 다른 글
| C# 개미퀴즈 프로그램 (2) | 2007/07/16 |
|---|---|
| C#으로 짜본 야구게임 (0) | 2007/07/16 |
| 4의배수 크기 마방진 알고리즘 (1) | 2007/07/13 |
| Taylor Sin(x) (0) | 2007/07/12 |
| Taylor Series - Exp(x) 구현 (0) | 2007/07/12 |
| .NET에서 UnixTimestamp의 구현 (0) | 2007/05/29 |

Prev



