Demo entry 6313662

No.5

   

Submitted by Max Lin on Oct 26, 2016 at 11:30
Language: C. Code size: 3.9 kB.

#include "stdio.h"
#include "subk.c"
#include "subf.c"
#include "draw.c"
#include "graphics.h"
main()
{
    static double p[20][2], vp[20][2], ap[20][2], del;
    static double t[10], w[10], e[10], tbdraw[370], tb8draw[370];
    static double sita1[370],fr1draw[370],sita2[370],fr2draw[370],sita3[370],fr3draw[370];
    static double fr[20][2], fe[20][2], tb, tb8, fr1, bt1, fr4, bt4, fr8, bt8, we1, we2, we3;
    static int ic;
    double r78, r16, r67, r12, r23, r34, r25, r19, r210, r411;
    double pi, dr; 
    int i;
    FILE *fp;
    char *m[]={"tb", "tb1", "fr1", "fr4", "fr8"};
    sm[1]=3500; sm[2]=3600; sm[3]=5500; sm[4]=0; sm[5]=0;
    sj[1]=0; sj[2]=0; sj[3]=0; sj[4]=0; sj[5]=0;
    r78=1.39; r67=2.78; r16=4.0; r12=28.525; r23=3.625; r34=25.15; r25=8.35;
    r19=8.5; r210=1.0; r411=2.5;
    pi=4.0*atan(1.0);
    dr=pi/180.0;
    w[5]=0.11; e[5]=0.0;
    p[1][1]=0.0; p[1][2]=0.0;
    p[4][1]=5.6; p[4][2]=8.1;
    p[8][1]=2.86; p[8][2]=4.0;
    del=15.0;
    printf("\n Kineto-static Analysis of the Dock Crane \n");
    printf("No THETA1 fr1 sita1 fr4 sita4 fr8 sita8 tb tb8\n");
    printf("   deg    N  radian N  radian N  radian N*m N*m\n");
    if((fp=fopen("FILE5", "w"))==NULL)
    {
    	printf("Cannot open this file.\n");
    	exit(0);	
    }
    fprintf(fp, "\n Kineto-static Analysis of the Dock Crane \n");
    fprintf(fp, "No THETA1 fr1 sita1 fr4 sita4 fr8 sita8 tb tb8\n");
    fprintf(fp, "   deg    N  radian N  radian N  radian N*m N*m\n");
    ic=(int)(360.0/del);
    for(i=0; i<=ic; i++)
    {
	t[5]=(i*del)*dr;  
        bark(8, 7, 0, 5, r78, 0.0, 0.0, t, w, e, p, vp, ap);
	rrrk(1, 1, 7, 6, 1, 4, r16, r67, t, w, e, p, vp, ap);
        bark(1, 0, 2, 1, 0.0, r12, 25.0*dr, t, w, e, p, vp, ap);
	rrrk(1, 2, 4, 3, 2, 3, r23, r34, t, w, e, p, vp, ap);
        bark(2, 0, 5, 2, 0.0, r25, 176.0*dr, t, w, e, p, vp, ap);
        bark(1, 0, 9, 1, 0.0, r19, 18.0*dr, t, w, e, p, vp, ap);
        bark(2, 0, 10, 2, 0.0, r210, 95.0*dr, t, w, e, p, vp, ap);
        bark(4, 0, 11, 3, 0.0, r411, -156.0*dr, t, w, e, p, vp, ap);
	rrrf(2, 4, 3, 10, 11, 5, 0, 5, 2, 3, p, vp, ap, t, w, e, fr);
	rrrf(1, 7, 6, 9, 0, 2, 0, 0, 1, 4, p, vp, ap, t, w, e, fr);
        barf(8, 0, 7, 5, p, ap, e, fr, &tb); 
        fr1=sqrt(fr[1][1]*fr[1][1]+fr[1][2]*fr[1][2]);
        bt1=atan2(fr[1][2], fr[1][1]);
        fr4=sqrt(fr[4][1]*fr[4][1]+fr[4][2]*fr[4][2]);
        bt4=atan2(fr[4][2], fr[4][1]);
        fr8=sqrt(fr[8][1]*fr[8][1]+fr[8][2]*fr[8][2]);
        bt8=atan2(fr[8][2], fr[8][1]);
        we1=-(ap[9][1]*vp[9][1]+(ap[9][2]+9.8)*vp[9][2])*sm[1]-e[1]*w[1]*sj[1];      
        we3=-(ap[11][1]*vp[11][1]+(ap[11][2]+9.8)*vp[11][2])*sm[3]-e[3]*w[3]*sj[3];
        we2=-(ap[10][1]*vp[10][1]+(ap[10][2]+9.8)*vp[10][2])*sm[2]+fe[5][2]*vp[5][2]+fe[5][1]*vp[5][1];
	extf(p, vp, ap, t, w, e, 5, fe);	
        tb8=-(we1+we2+we3)/w[5]; 
	printf("\n%2d %10.3f %10.3f %10.3f %10.3f %10.3f %10.3f %10.3f %10.3f %10.3f", i+1, t[1]/dr, fr1, bt1/dr, fr4, bt4/dr, fr8/dr, bt8/dr, tb, tb8);
	fprintf(fp,"\n%2d %10.3f %10.3f %10.3f %10.3f %10.3f %10.3f %10.3f %10.3f %10.3f", i+1, t[1]/dr, fr1, bt1/dr, fr4, bt4/dr, fr8/dr, bt8/dr, tb, tb8);
	tbdraw[i]=tb;
        tb8draw[i]=tb8;
        fr1draw[i]=fr1;
	sita1[i]=bt1;
        fr2draw[i]=fr4;
	sita2[i]=bt4;
        fr3draw[i]=fr8;
	sita[3]=bt8;                                                                                        
	if((i%16)==0){getch();}
    }
    fclose(fp);
    getch();
    draw2(del, tbdraw, tb8draw, ic, m);
    draw3(del, sita1, fr1draw, sita2, fr2draw, sita3, fr3draw, ic, m);
}
extf(p, vp, ap, t, w, e, nexf, fe)
double p[20][2], vp[20][2], ap[20][2], t[10], w[10], e[10], fe[20][2];
int nexf;
{
	if(vp[nexf][1]>0)
	{
		fe[nexf][1]=0.0;
		fe[nexf][2]=0.0;
	}
	else
	{
		fe[nexf][1]=50000/9.8*ap[5][1];
		fe[nexf][2]=-50000/9.8*(ap[5][2]+9.8);	
	}
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).