序号:1学号:12477218CHANGZHOUUNIVERSITY课程设计课程设计名称:繁花曲线学院名称:信息科学与工程学院学生姓名:孙剑峰小组成员:孙剑峰陈菲陈菲夏园园何凯.设计时间:2013年06月17日2013年06月28日目录“繁花曲线”任务书..........................................02一、翻译..........................................................03二、程序概述...................................................07三、结构框图...................................................07四、程序代码...................................................07五、使用说明...................................................18六、心得体会...................................................181繁华曲线任务书一、目的要求本课程设计任务的目的是要求学生按照分析、设计、编码、调试和测试的软件开发过程独立完成一个绘图程序,并能最终实现本系统的功能要求。本任务必须完成拓展练习一。二、功能要求【题目描述】有一种玩具叫做繁花曲线规,它由一套彩色塑料齿轮组成。一个大齿轮是环状的,牙齿做在里面;几个小齿轮的牙齿做在外面,小齿轮内部有一些小圆孔和几个其它形状的、较大的孔。使用时左手按住大齿轮,让它紧贴在纸上,不能移动。在大齿轮里放一只小齿轮,把笔尖插进小齿轮的某一个孔里,让小齿轮紧贴大齿轮内壁滚动,这时笔尖就会在纸上画出许多美丽的曲线花纹。图1繁华曲线规所作出的图繁花曲线规的原理可以用下图图2繁花曲线原理图设大圆半径为R,小圆半径为r,小圆上孔距小圆圆心为t。当小圆在大圆内转动时,小圆圆心与大圆圆心构成转动后的角度α,由于小圆与大圆走过的圆弧长度相同(齿啮合)所以小圆转过的圆弧β可通过α与R和r计算得到。则小圆上的小孔新的坐标也可计算得到。题目要求:使用你的数学能力计算出繁花曲线上的每一点的坐标公式,变换你的画笔的线型,线宽,色彩,使用循环描绘出美丽的图形。要求1:通过菜单生成对话框输入大圆半径R,小圆半径r和小孔位置t,画出单色调的繁花曲线。要求2:通过不同的菜单绘制4幅不同的预定义的彩色繁花曲线,其中包括图一两幅图案。11一、翻译AboutLinesandCurves0outof2ratedthishelpful-RatethistopicManytypesofapplicationsuselinesandcurvestodrawgraphicsoutputonrasterdevices.Computer-aideddesign(CAD)anddrawingapplicationsuselinesandcurvestooutlineobjects,specifythecentersofobjects,thedimensionsofobjects,andsoon.Spreadsheetapplicationsuselinesandcurvestodrawgrids,charts,andgraphs.Wordprocessingapplicationsuselinestocreaterulesandbordersonapageoftext.LineTofunction1outof2ratedthishelpful-RatethistopicTheLineTofunctiondrawsalinefromthecurrentpositionupto,butnotincluding,thespecifiedpoint.SyntaxBOOLLineTo(_In_HDChdc,_In_intnXEnd,_In_intnYEnd);Parameters2hdc[in]Handletoadevicecontext.nXEnd[in]Specifiesthex-coordinate,inlogicalunits,oftheline'sendingpoint.nYEnd[in]Specifiesthey-coordinate,inlogicalunits,oftheline'sendingpoint.ReturnvalueIfthefunctionsucceeds,thereturnvalueisnonzero.Ifthefunctionfails,thereturnvalueiszero.RemarksThelineisdrawnbyusingthecurrentpenand,ifthepenisageometricpen,thecurrentbrush.IfLineTosucceeds,thecurrentpositionissettothespecifiedendingpoint.ExamplesForanexample,seeDrawingMarkers.3MoveToExfunction1outof2ratedthishelpful-RatethistopicTheMoveToExfunctionupdatesthecurrentpositiontothespecifiedpointandoptionallyreturnsthepreviousposition.SyntaxBOOLMoveToEx(_In_HDChdc,_In_intX,_In_intY,_Out_LPPOINTlpPoint);Parametershdc[in]Handletoadevicecontext.X[in]Specifiesthex-coordinate,inlogicalunits,ofthenewposition,inlogicalunits.Y[in]Specifiesthey-coordinate,inlogicalunits,ofthenewposition,inlogicalunits.lpPoint[out]PointertoaPOINTstructurethatreceivesthepreviouscurrent4position.IfthisparameterisaNULLpointer,thepreviouspositionisnotreturned.ReturnvalueIfthefunctionsucceeds,thereturnvalueisnonzero.Ifthefunctionfails,thereturnvalueiszero.RemarksTheMoveToExfunctionaffectsalldrawingfunctions.ExamplesForanexample,seeDrawingMarkers.5二、程序概述主要功能:1、用户能够通过菜单打开对话框输入大圆半径R,小圆半径r和小孔位置t(分为小圆上的小孔半径t1和大圆上的小孔半径t2),画出单色调的繁花曲线。2、用户能够通过不同的菜单绘制4幅不同的预定义的彩色繁花曲线。三、结构框图四、程序代码#includestdafx.h#includestdio.h#includeresource.h#includestdlib.h#includemath.h#defineMAX_LOADSTRING100structcurve{doubleR;doublerr;doublet1;doublet2;}Curve,Cur[12];ints[4]={0},C;HINSTANCEhInst;TCHARszTitle[MAX_LOADSTRING];TCHARszWindowClass[MAX_LOADSTRING];ATOMMyRegisterClass(HINSTANCEhInstance);BOOLInitInstance(HINSTANCE,int);LRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);LRESULTCALLBACKAbout(HWND,UINT,WPARAM,LPARAM);开始输入R,r,t1,t2的值用户自定义菜单输出单色繁花曲线结束程序预设菜单开始用户通过菜单选择预定义繁花曲线图输入绚丽繁花曲线结束6intAPIENTRYWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdLine,intnCmdShow){MSGmsg;HACCELhAccelTable;LoadString(hInstance,IDS_APP_TITLE,szTitle,MAX_LOADSTRING);LoadString(hInstance,IDC_FLOVERCURVE,szWindowClass,MAX_LOADSTRING);MyRegisterClass(hInstance);if(!InitInstance(hInstance,nCmdShow)){returnFALSE;}hAccelTable=LoadAccelerators(hInstance,(LPCTSTR)IDC_FLOVERCURVE);while(GetMessage(&msg,NULL,0,0)){if(!TranslateAccelerator(msg.hwnd,hAccelTable,&msg)){TranslateMessage(&msg);DispatchMessage(&msg);}}returnmsg.wParam;}ATOMMyRegisterClass(HINSTANCEhInstance){WNDCLASSEXwcex;wcex.cbSize=sizeof(WNDCLASSEX);wcex.style=CS_HREDRAW|CS_VREDRAW;wcex.lpfnWndProc=(WNDPROC)WndProc;wcex.cbClsExtra=0;wcex.cbWndExtra=0;wcex.hInstance=hInstance;wcex.hIcon=LoadIcon(hInstance,(LPCTSTR)IDI_FLOVERCURVE);wcex.hCursor=LoadCursor(NULL,IDC_ARROW);wcex.hbrBackground=(HBRUSH)(COLOR_WINDOW+1);wcex.lpszMenuName=(LPCSTR)IDC_FLOVERCURVE;wcex.lpszClassName=szWindowClass;wcex.hIconSm=LoadIcon(wcex.hInstance,(LPCTSTR)IDI_SMALL);returnRegisterClassEx(&wcex);}BOOLInitInstance(HINSTANCEhInstance,intnCmdShow){HWNDhWnd;hInst=hInstance;hWnd=CreateWindow(szWindowClass,szTitle,WS_OVERLAPPEDWINDOW,7CW_USEDEFAULT,0,CW_USEDEFAULT,0,NULL,NULL,hInstance,NULL);if(!hWnd){returnFALSE;}ShowWindow(hWnd,nCmdShow);UpdateWindow(hWnd);returnTRUE;}LRESULTCALLBACKInput(HWNDhDlg,UINTmessage,WPARAMwParam,LPARAMlParam){switch(message){caseWM_INITDIALOG:{SetDlgItemInt(hDlg,ID