How to make a circle acquire pure rolling from start?

Hey, I’ve initiated the following code and now I want that the circle (with a spoke in it) performs pure rolling or it looks that it actually moves in real sense.
Can anybody tell me how to do it?

#include<stdio.h>
#include<graphics.h>
#include<math.h>
#include<conio.h>
#include<dos.h>

int xc=0, yc=200, r;
int x[15], y[15];
void motioncircle()
{
circle(xc, yc, r);
}
void main()
{
double angle=0, theta;
int i, a;
int gd=DETECT, gm;
initgraph(&gd, &gm,"…\bgi");
printf(“Enter r: “);
scanf(”%d”, &r);
a=xc+r;
while(!kbhit())
{
while(a<=630)
{
theta=M_PIangle/180;
cleardevice();
motioncircle();
for(i=0; i<1; i++)
{
theta=M_PI
angle/180;
x[i]=xc+rcos(theta);
y[i]=yc+r
sin(theta);
angle+=20;
line(xc, yc, x[i], y[i]);
}
angle+=2;
xc+=2;
a=xc+r;
delay(50);
}
xc=0;
a=xc+r;
}
getch();
closegraph();
}

For the circle to accquire pure rolling or to at least be seen that it is actually “rolling” you might want to plug in the equations for a “cycloid”.

A cycloid is a special type of curve which can actually simulate what you need:

“A cycloid is the curve traced by a point on the rim of a circular wheel as the wheel rolls along a straight line without slippage.”

Note that this is more a Physics question than a programming one, but, basically if the circle rolls without slippage than that means that for you to simulate a rotation, all you need to do is make the circle “slide” horizontally with constant velocity and couple a cycloid like motion to it.

If you do that, then you can literally obtain the figure which is on the wikipedia link.

Maybe this helps,

Bruno Oliveira

Brilliant buddy…
And, thanks for the link as well.

You’re welcome and thanks for marking answer as accepted :slight_smile: Almost nobody does it :stuck_out_tongue:

1 Like
//