vc++编程绘图.doc

上传人:asd****56 文档编号:70332807 上传时间:2023-01-19 格式:DOC 页数:14 大小:255.50KB
返回 下载 相关 举报
vc++编程绘图.doc_第1页
第1页 / 共14页
vc++编程绘图.doc_第2页
第2页 / 共14页
点击查看更多>>
资源描述

《vc++编程绘图.doc》由会员分享,可在线阅读,更多相关《vc++编程绘图.doc(14页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、2-1源程序:#include”math.h”void CHhhh02View:OnDraw(CDC* pDC)CHhhh02Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);CRect r;GetClientRect(r);pDC-SetMapMode(7);pDC-SetWindowOrg(0,0);pDC-SetViewportOrg(r.right/2,r.bottom/2);pDC-SetWindowExt(200,100);pDC-SetViewportExt(100,-80);int pp142=0,0, 0,120, -240,0, 24

2、0,0, 0,120, -160,0, -160,40,-80,0, -80,80, 0,0, 80,80, 80,0, 160,40, 160,0;pDC-MoveTo(pp00,pp01);for(int i=1;iLineTo(ppi0,ppi1); pDC-MoveTo(pp50,pp51);for(i=6;iLineTo(ppi0,ppi1);2-1运行结果:2-2源程序: #includemath.hvoid CMy13View:OnDraw(CDC* pDC)CMy13Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);CRect r;Get

3、ClientRect(r); pDC-SetMapMode(7);pDC-SetWindowOrg(0,0);pDC-SetViewportOrg(r.right/4,r.bottom/2);pDC-SetWindowExt(200,100);pDC-SetViewportExt(200,-100);for(int i=1;iSelectObject(pi);pDC-MoveTo(300,100);pDC-Arc(300-10*i,100,300+10*i,100-20*i,300,100,300,100);2-2运行结果:2-3源程序:#includemath.hvoid CMy24View

4、:OnDraw(CDC* pDC)CRect r;GetClientRect(r); pDC-SetMapMode(7);pDC-SetWindowOrg(0,0);pDC-SetViewportOrg(r.right/2,r.bottom/2);pDC-SetWindowExt(100,100);pDC-SetViewportExt(100,-100); CPen p1(0,2,RGB(0,0,0);double p352,p252;double a=3.1415926;for(int i=0;iMoveTo(0,0);pDC-SelectObject(p1);for( i=0;iMoveT

5、o(0,0); pDC-LineTo(p3i0,p3i1); pDC-LineTo(p2i0,p2i1); pDC-MoveTo(0,0); pDC-LineTo(p2i0,p2i1); pDC-LineTo(p3i+10,p3i+11); pDC-MoveTo(p240,p241); pDC-LineTo(p300,p301);2-3运行结果:2-4源程序:void CMy2_4View:OnDraw(CDC* pDC)CMy2_4Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);CRect r;GetClientRect(r); pDC-SetMap

6、Mode(7);pDC-SetWindowOrg(0,0);pDC-SetViewportOrg(r.right/2,r.bottom*3/4);pDC-SetWindowExt(200,100);pDC-SetViewportExt(400,-200);double p142=0,0,10,0,90,0,80,10,20,10,20,70,10,80,10,100,0,100,0,80,-10,70,-10,10,-70,10,-80,0; pDC-MoveTo(p130,p131);pDC-LineTo(p20,p21);pDC-MoveTo(p00,p01);pDC-LineTo(p80

7、,p81);pDC-MoveTo(p10,p11);pDC-LineTo(p70,p71);pDC-MoveTo(p70,p71);pDC-LineTo(p80,p81);pDC-MoveTo(p110,p111);pDC-LineTo(p120,p121);pDC-MoveTo(p30,p31);pDC-LineTo(p40,p41);pDC-MoveTo(p100,p101);pDC-LineTo(p110,p111);pDC-MoveTo(p40,p41);pDC-LineTo(p50,p51);pDC-Arc(70,10,90,-10,90,0,80,10);pDC-Arc(0,80,

8、20,60,20,70,10,80);pDC-Arc(-10,80,10,60,0,80,-10,70);pDC-Arc(-80,10,-60,-10,-70,10,-80,0);2-4运行结果:2-5源程序:#include math.hvoid CHhhh01View:OnDraw(CDC* pDC)CHhhh01Doc* pDoc = GetDocument();ASSERT_VALID(pDoc); CRect r ; GetClientRect(r);CPen p01(0,8,RGB(0,0,0),p02(1,0,RGB(255,0,0);pDC-SetMapMode(7);pDC-

9、SetWindowExt(200,100);pDC-SetViewportExt(100,-50);pDC-SetWindowOrg(0,0);pDC-SetViewportOrg(r.right/2,r.bottom/2);int pp102=0,125, -280,125, -280,-100, 280,-100, 280,125, 0,125, -60,0, -60,-100, 60,0,60,-100;pp00=-sqrt(150*150-125*125);pp50=-pp00;pp61=-sqrt(100*100-60*60);pp81=pp61; pDC-SelectObject(

10、p01);pDC-MoveTo(pp00,pp01);for(int i=1;iLineTo(ppi0,ppi1);pDC-MoveTo(pp60,pp61); pDC-LineTo(pp70,pp71);pDC-MoveTo(pp80,pp81); pDC-LineTo(pp90,pp91);pDC-Arc(-150,-150,150,150,pp50,pp51,pp00,pp01);pDC-Arc(-100,-100,100,100,pp80,pp81,pp60,pp61);pDC-SelectObject(p02);pDC-MoveTo(-110,0); pDC-LineTo(110,0

11、); pDC-MoveTo(0,-110); pDC-LineTo(0,160);2-5运行结果:2-6源程序:void CMy1View:OnDraw(CDC* pDC)CMy1Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);CRect r;GetClientRect(r); pDC-SetMapMode(7);pDC-SetWindowOrg(0,0);pDC-SetViewportOrg(r.right/2,r.bottom/2);pDC-SetWindowExt(200,100);pDC-SetViewportExt(200,-100);CPe

12、n p1(0,1,RGB(255,0,0); pDC-SelectObject(p1);pDC-MoveTo(0,0);pDC-Arc(-70,70,70,-70,70,0,-70,0); pDC-SetArcDirection(AD_COUNTERCLOCKWISE); pDC-Arc(-140,50,140,-50,-52.45,46.36,52.45,46.36);2-6运行结果:2-7源程序:#includemath.hvoid CMy2_7View:OnDraw(CDC* pDC)CMy2_7Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);C

13、Rect r;GetClientRect(r); double a=3.1415926; pDC-SetMapMode(7);pDC-SetWindowOrg(0,0);pDC-SetViewportOrg(r.right/2,r.bottom/2);pDC-SetWindowExt(200,100);pDC-SetViewportExt(600,-300);pDC-Ellipse(-30,30,30,-30); pDC-Ellipse(-30*cos(60*a)/180),30,30*cos(60*a)/180),-30); pDC-Arc(-30*cos(30*a)/180),30,30*

14、cos(30*a)/180),-30,0,30,0,30); for(int i=-20;iMoveTo(-sqrt(30*30-i*i),i); pDC-LineTo(sqrt(30*30-i*i),i);2-7运行结果:2-8源程序:#includemath.h#define R(theta) (cos(1.5*theta)*s1void Cmy110View:OnDraw(CDC* pDC)CMy2Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);/ TODO: add draw code for native data hereint x0,y0

15、,x,y,s1=120;double r,theta;CRect rc;GetClientRect(&rc);x0=rc.right/2;y0=rc.bottom/2;pDC-SetMapMode(7);pDC-SetWindowExt(200,100);pDC-SetViewportExt(200,-100);pDC-SetViewportOrg(x0,y0);for(theta=0;thetaMoveTo(0,0);pDC-LineTo(x,y);2-8运行结果:2-10源程序:#includemath.hvoid CMy2_95View:OnDraw(CDC* pDC)CMy2_95Do

16、c* pDoc = GetDocument();ASSERT_VALID(pDoc);CRect r;GetClientRect(r); pDC-SetMapMode(7);pDC-SetWindowOrg(0,0);pDC-SetViewportOrg(r.right/2,r.bottom/2);pDC-SetWindowExt(200,100);pDC-SetViewportExt(400,-200);pDC-Ellipse(-70,70,70,-70);pDC-Arc(-75,75,75,-75,75,-75,75,-75);double d=45;for(int i=(-60);iMo

17、veTo (-sqrt(70*70-i*i)*cos(d)-i*sin(d),(-sqrt(70*70-i*i)*sin(d)+i*cos(d);pDC-LineTo (sqrt(70*70-i*i)*cos(d)-i*sin(d),(sqrt(70*70-i*i)*sin(d)+i*cos(d);2-9运行结果:2-10源程序:void Cmy110View:OnDraw(CDC* pDC)CMy6Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);CRect r;GetClientRect(r); pDC-SetMapMode(7);pDC-SetWi

18、ndowOrg(0,0);pDC-SetViewportOrg(r.right/3,r.bottom*2/3);pDC-SetWindowExt(200,100);pDC-SetViewportExt(200,-100); CPen p1(0,1,RGB(0,0,0);pDC-SelectObject(p1);for(int i=0;iMoveTo(20*i,20*i*0.4);pDC-LineTo(20*(i+1),20*(i+1)*0.4); pDC-LineTo(20*(i+1),65+20*(i+1)*0.4); pDC-LineTo(20*i,65+20*i*0.4); pDC-Li

19、neTo(20*i,20*i*0.4);for( i=0;iMoveTo(40*i,40*i*0.4);pDC-LineTo(40*i,-20+40*i*0.4);2-10运行结果:2-11源程序:#include math.h#define x(t) a*cos(t)*cos(phi*3.1415926/180)-b*sin(t)*sin(phi*3.1415926/180)+xo#define y(t) a*cos(t)*sin(phi*3.1415926/180)+b*sin(t)*cos(phi*3.1415926/180)+yovoid CMy10View:OnDraw(CDC* p

20、DC)CMy10Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);CRect rc; GetClientRect(rc); pDC-SetMapMode(7); pDC-SetViewportOrg(rc.right/2,rc.bottom/2); pDC-SetWindowExt(100,100); pDC-SetViewportExt(100,-100); for(double phi=0;phi(180-180/8);phi+=180/8) elli(0,0,100,40,phi);void CMy10View:elli(int xo, int y

21、o, double a, double b, double phi) CClientDC dc(this); CRect rc; GetClientRect(rc); dc.SetMapMode(7); dc.SetViewportOrg(rc.right/2,rc.bottom/2); dc.SetWindowExt(100,100); dc.SetViewportExt(100,-100); for(double t=0; tSetTextColor(RGB(255,0,0);CPen p1(0,1,RGB(255,0,0); pDC-SelectObject(p1);pDC-TextOu

22、t(m,j,k);pDC-GetTextMetrics(&tm);j+=tm.tmHeight+10*tm.tmExternalLeading;int s=1; double s1=0.5;double x0=rc.right/2;double y0=rc.bottom/2+100;draw(x0,y0,s,s1);s=-s;draw(x0,y0,s,s1);void CMy212View:draw(double x0, double y0, int s, double s1)int i;CClientDC dc(this);dc.MoveTo(fnx(0),fny(50);dc.LineTo

23、(fnx(300),fny(50);dc.Rectangle(fnx(165),fny(50),fnx(215),fny(250);dc.Rectangle(fnx(155),fny(250),fnx(225),fny(260);dc.Arc(fnx(190-25),fny(260-25),fnx(190+25),fny(260+25),x0+300,fny(260),x0-300,fny(260);dc.MoveTo(fnx(215),fny(55);dc.LineTo(fnx(300),fny(55);dc.MoveTo(fnx(215),fny(190);dc.LineTo(fnx(300),fny(190);dc.MoveTo(fnx(215),fny(195);dc.LineTo(fnx(300),fny(195);for(i=1;i=4;i+)dc.MoveTo(fnx(215+20*i),fny(55);dc.LineTo(fnx(215+20*i),fny(190);2-12运行结果:土木工程2008级Vc+编程绘图指导教师 韩太昌 班级 土木八班 姓名 学号 20080235 西南交通大学土木工程学院2009年11月14

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 其他杂项

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁