0% found this document useful (0 votes)
55 views5 pages

C Program for Hypo-cycloid Animation

The document describes a C program to animate a hypo-cycloid curve. The program allows the user to enter the radius of the circle and path. It uses equations to calculate the x and y coordinates of the moving circle at different angles and plots these points over time to show the curve's animation. The program code includes declarations, input of radii, calculations of sine and cosine values, storing of x and y coordinates in arrays, plotting of points, and use of delays to create the animation effect.

Uploaded by

Vishal Gore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views5 pages

C Program for Hypo-cycloid Animation

The document describes a C program to animate a hypo-cycloid curve. The program allows the user to enter the radius of the circle and path. It uses equations to calculate the x and y coordinates of the moving circle at different angles and plots these points over time to show the curve's animation. The program code includes declarations, input of radii, calculations of sine and cosine values, storing of x and y coordinates in arrays, plotting of points, and use of delays to create the animation effect.

Uploaded by

Vishal Gore
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Vishal gore

P17CC006
C PROGRAM
1. Write a C program to show animation of “Hypo-cycloid” curve in which user can
enter radius of circle and radius of path.

x ( θ ) = ( R – r ) cos θ + r cos [ ( R – r ) θ r ]
y ( θ ) = ( R – r ) sin θ – r sin [ ( R – r ) θ r ]

where r is the radius of the moving circle, R is the radius of the fixed circle and θ is
the angle between the radius vector of the centre of the moving circle with the x-axis.

C PROGRAM CODE:
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<math.h>
#include<stdio.h>

void main()
{
clrscr();

int driver = DETECT, mode;


initgraph(&driver, &mode, "c:\\turboc3\\bgi");

int counter,j;

float i;
float t,t_rad;
float cap_r,sml_r,cap_sml;
float sin_t,cos_t;
float t1,t2,cos_t2,sin_t2,x1,x2,x,y1,y2,y;
float c_x,c_y;
float x_loc[500],y_loc[500];
float plot_c_x,plot_c_y;

plot_c_x=200;
plot_c_y=200;
printf("\n enter the value of r");
scanf("%f",&cap_r);

sml_r = cap_r/3;
cap_sml = cap_r-sml_r;

setcolor(YELLOW);
circle(plot_c_x,plot_c_y,cap_r);

t = 360;
counter = 1;

for(i=1;i<=t;i=i+1)
{
t_rad = (i/180)*(3.14);
sin_t = sin(t_rad);
cos_t = cos(t_rad);
t1 = cap_sml*t_rad;
t2 = t1/sml_r;
cos_t2 = cos(t2);
sin_t2 = sin(t2);

x1=cap_sml*cos_t;
x2=sml_r*cos_t2;
x=x1+x2;

y1=cap_sml*sin_t;
y2=sml_r*sin_t2;
y=y1-y2;

c_x = cap_sml*cos_t;
c_y = cap_sml*sin_t;
//printf("%.2f\t%.2f\n",x,y);
setcolor(YELLOW);
circle(plot_c_x,plot_c_y,cap_r);
setcolor(WHITE);
circle(c_x+plot_c_x,c_y+plot_c_y,sml_r);

x_loc[counter]=x+plot_c_x;
y_loc[counter]=y+plot_c_y;

for(j=1;j<=counter;j++)
{
putpixel(x_loc[j],y_loc[j],3);
}

delay(10);
setcolor(BLACK);
circle(c_x+plot_c_x,c_y+plot_c_y,sml_r);

counter = counter+1;

setcolor(WHITE);
circle(c_x+plot_c_x,c_y+plot_c_y,sml_r);

getch();
closegraph();
}
OUTPUT:

You might also like