[FSF India] gtk help
Ajith Kumar
fsf-india@gnu.org.in
Fri, 03 Aug 2001 10:40:08 +0530
This is a multi-part message in MIME format.
--------------F77F8E5E7110A8E56215B3DB
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hello
can anyone help in converting this to gtk undel GNU/Linux.
ajith
--------------F77F8E5E7110A8E56215B3DB
Content-Type: text/plain; charset=us-ascii;
name="cfm.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="cfm.c"
//PROG.001: MOTION OF A PARTICLE IN CENTRAL FORCE FILELD
// Program name: CFM.C
#include <math.h>
#include <graphics.h>
#include <stdio.h>
#define PI 3.141
main()
{
int gd=DETECT,gm,maxx,maxy,xpt,ypt,i;
float vel,dir_rad,dir_theta,ax,ay,t,Tmax,dt=0.01;
float vx,vy,x,y,dx,dy,dvx,dvy,r,k=-25,m=0.10;
float accel(float,float,float,float);
printf("\nEnter position x,y ");
scanf("%f,%f",&x,&y);
printf("\nEnter velocity and direction ");
scanf("%f,%f",&vel,&dir_theta);
printf("\nEnter max. time of study (s)");
scanf("%f",&Tmax);
dir_rad=dir_theta*PI/180.0;
vx=vel*cos(dir_rad);
vy=vel*sin(dir_rad);
initgraph(&gd,&gm,"d:\\tc\\bgi");
maxx=getmaxx();
maxy=getmaxy();
setcolor(GREEN);
setviewport(120,40,520,440,1);
rectangle(0,0,400,400);
putpixel(200,200,RED);
for(i=0;i<=400;i=i+5)
{
putpixel(i,200,BLUE);
putpixel(200,i,BLUE);
}
for(t=0;t<=Tmax;t=t+dt)
{
r=sqrt(x*x + y*y);
ax=accel(x,r,k,m);
ay=accel(y,r,k,m);
vx=vx+ax*dt;
vy=vy+ay*dt;
x=x+vx*dt;
y=y+vy*dt;
xpt=(x+20)*400/40;
ypt=400-(y+20)*400/40;
putpixel(xpt,ypt,YELLOW);
delay(10);
}
printf("\n PARTICLE MOVING IN A CENTRAL FORCE FIELD");
printf("\nk=%4.2f(SIu)",k);
printf("\nV=%4.2fm/s",vel);
printf("\nang=%4.2fd",dir_theta);
printf("\nmass=%4.2fkg",m);
sound(100);
delay(100);
nosound();
getch();
restorecrtmode();
}
// Modify this function for differet types of
// central forces
float accel(float a, float d, float fk, float mass)
{
float acc;
acc=fk*a/(mass*d*d*d);
return(acc);
}
--------------F77F8E5E7110A8E56215B3DB
Content-Type: text/x-vcard; charset=us-ascii;
name="ajith.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Ajith Kumar
Content-Disposition: attachment;
filename="ajith.vcf"
begin:vcard
n:Kumar;Ajith
x-mozilla-html:FALSE
org:Nuclear Science Centre
adr:;;;;;;
version:2.1
email;internet:ajith@nsc.ernet.in
title:Scientist SE
x-mozilla-cpt:;28064
fn:Ajith Kumar
end:vcard
--------------F77F8E5E7110A8E56215B3DB--