机械原理c语言程序,c语言机械原理编程,连杆运动分析图线.docx

编程大作业

基于 C 语言的机械原理分析图:

只有库函数包含头文件:graphics.h

conio.h

才能观看该程序效果;

若已经安装 VC++,可以打开文件夹里面的 EasyX压缩包, 并安装 EasyX文件, 也可以观看程序效果;

一、角度与l3 与角 1 的关系;

#include

#include

#include

#include

#define SZ 2

#define PI 3.1415926

float c[SZ][SZ]={0};

void danwei()

{

char s[5];

int i=0;

int k=-5;

while(k<=600)

{

sprintf(s, "%d", i);

outtextxy(k, 5, s);

k+=75;

i+=45;

}

outtextxy(280,25, " θ1/ 度 ");

}

void danwei2()

{

char s[10];

float i= -0.1;

int k=-10;

while(k>= -400)

{

sprintf(s,"%0.2f",i);

outtextxy(610,k,s);

k-=40;

i+=0.05;

}

outtextxy(610, -420, "l3/m/s");

}

void danwei1()

{

char s[10];

int i= -60;

int k=-10;

while(k>= -400)

{

sprintf(s,"%d",i);

outtextxy( -30,k,s);

k-=20;

i+=10;

}

outtextxy( -85,-420, " θ 2、θ 3/ 度");

}

int main()

{

创建大小为 800 * 600 的绘图窗口

initgraph(800, 600);

设置原点 (0, 0) 为屏幕中央( Y 轴默认向下为正)

setorigin(100, 500);

使用白色填充背景

setbkcolor(WHITE);

cleardevice();

setlinecolor(RGB(7, 190, 234));

rectangle(0, -400,600,0);

int i,j;

网格线

for(i=0;i<600;i=i+20)

line(i,0,i, -400);

for(j=0;j<400;j=j+20)

line(0, -j,600, -j);

输出屏幕提示

settextcolor(BLACK);

setfont(18,0," 宋体 ");

danwei();

danwei1();

settextcolor(RED);

danwei2();

settextcolor(RGB(201, 62, 0));

outtextxy(240, -450, "角度关系图 ");

float o3,o1,o2,w1=10;

float temp1;

float l1=0.100,l2=0.040,l4=0.200;

float l3,m,m1,A,B,C,D;

float a[2][2]={0},b[2][1]={0},a1[2][2]={0};

float k,t,m10=0,t10= -16.2602*40/20 -120,m11=0,

t11=(-(16.2602+90))*40/20 -120,m12=0,t12= -0.22*40/(0.05) -80;

float n=0;

while(n<=360)

{

o1=n*PI/180;

A=l1*sin(o1) -l4;

B=l1*cos(o1);

C=-l2;

D=(A+sqrt(pow(A,2)+pow(B,2) -pow(C,2)))/(B -C);

o2=2*atan(D);

m=o2*180/PI;

l3=(l1*cos(o1) -l2*cos(o2))/sin(o2);

k=m;

m1=n*600/360;

t=-k*40/20 -120;

setcolor(BLACK);

line(m10,t10,m1,t);

m10=m1,t10=t;

k=m+90;

m1=n*600/360;

t=-k*40/20 -120;

setcolor(GREEN);

line(m11,t11,m1,t);

m11=m1,t11=t;

k=l3;

m1=n*600/360;

t=-k*40/(0.05) -80;

setcolor(MAGENTA);

line(m12,t12,m1,t);

m12=m1,t12=t;

n+=0.1;

}

settextcolor(GREEN);

outtextxy(160, -80, " θ 2");

ou

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值