void DrawSinLine(Graphics gph,Pen p)
{
//1. 中心原點 260 150 以120像素高 爲單位1 以120像素寬爲pi
double d = -6.2;
while (d <= 6.283)
{
double dbl = Math.Sin(d);
//Console.WriteLine("sin:{0}",dbl);
//計算座標 120 爲pi
double px, py;
if (d < 0)
{
px = 250 - Math.Abs(d) * 120 / Math.PI; // x
}
else
{
px = d * 120 / Math.PI + 250;
}
//----------------計算y的座標
if (dbl < 0)
{
py = Math.Abs(dbl) * 120 + 140; //y
}
else
{
py = 140 - (dbl * 120);
}
int x = (int)px + 10;
int y = (int)py + 10;
//Console.WriteLine("sin:x=>{0},y=>{1}", x, y);
p.Color = Color.Black;
gph.DrawLine(p, x, y, x, y);
d += 0.02;
}
p.Dispose(); //釋放資源
gph.Dispose();
}