 # How to make a circle acquire pure rolling from start?

#1

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, y;
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*=xc+rcos(theta);
y
=yc+rsin(theta);
angle+=20;
line(xc, yc, x
, y*);
}
angle+=2;
xc+=2;
a=xc+r;
delay(50);
}
xc=0;
a=xc+r;
}
getch();
closegraph();
}

#2

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

#3

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

#4

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