|
-
April 28th, 2011, 01:53 PM
#1
[RESOLVED] generating a sine wave
Hay guys,
I'm trying to generate a sine wave. I have some code but I don't know what i'm missing from it.
Any help or comments would be great.
[code]
void CSine_wave1View::OnPaint()
{
CPaintDC dc(this);
CRect Recto;
GetClientRect(&Recto);
CBrush bgBrush(BLACK_BRUSH);
dc.SelectObject(bgBrush);
dc.Rectangle(Recto);
CPen PenBlue(PS_SOLID,1,RGB(0,0,255));
dc.SelectObject(PenBlue);
for(int x=0; x<Recto.Width();x+=20)
{
dc.MoveTo(x,0);
dc.LineTo(x,Recto.Height());
}
for (int y=0; y<Recto.Height();y+=20)
{
dc.MoveTo(0,y);
dc.LineTo(Recto.Width(),y);
}
dc.SetMapMode(MM_ANISOTROPIC);
dc.SetViewportOrg(340,200);
dc.SetWindowExt(1000,200);
dc.SetViewportExt(1000,200);
double PI=3.14159;
int ScaleX=100;
int ScaleY=100;
for(double i=0;i<400; i+=0.01)
{
double j = sin(4*PI/ScaleX *i)* ScaleY;
dc.SetPixel(i,j,RGB(255,0,0));
}
}
[\code]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|