GDI实现正切曲线
求助,急 以下是用GDI绘制的正弦曲线,请高手帮助实现:正切曲线,区间是(-PI/2,PI/2),嘿嘿
#include <afxwin.h>
#include "Hello.h"
#include<math.h>
#define SEGMENTS 500
#define PI 3.1415926
CMyApp myApp;
/////////////////////////////////////////////////////////////////////////
// CMyApp member functions
BOOL CMyApp::InitInstance ()
{
m_pMainWnd = new CMainWindow;
m_pMainWnd->ShowWindow (m_nCmdShow);
m_pMainWnd->UpdateWindow ();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////
// CMainWindow message map and member functions
BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
ON_WM_PAINT ()
END_MESSAGE_MAP ()
CMainWindow::CMainWindow ()
{
Create (NULL, _T ("The Hello Application"));
}
void CMainWindow::OnPaint ()
{
CRect rect;
GetClientRect (&rect);
int nWidth=rect.Width ();
int nHeight=rect.Height ();
CPaintDC dc(this);
CPoint aPoint[SEGMENTS];
for (int i=0;i<SEGMENTS;i++){
aPoint[i].x=(i*nWidth)/SEGMENTS;
aPoint[i].y=(int)((nHeight/2)*
(1-(sin((2*PI*i)/SEGMENTS))));
}
dc.Polyline(aPoint,SEGMENTS);
}