GDI实现正切曲线

tiffinia tiffinia 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
求助,急 以下是用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);



}
...全文
评论 6
收藏 已收藏
分享
返回顶部
tiffinia
数据结构与算法 33,026 成员 35,334 内容