Tuesday, 11 August 2015

Implementation of forward kinematics - single link arm

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

void main(){
int gd = DETECT, gm;
int midx,midy;
float deg=45,angle,x1,y1;
 midx=320;midy=240;
 angle=deg*M_PI/180;
 initgraph(&gd,&gm,"C:\\TurboC3\\BGI");

 line(midx,midy,midx+100,midy);
 x1=(midx+100-midx)*cos(angle) - (midy-midy)*sin(angle) + midx;
 y1=(midx+100-midx)*sin(angle) + (midy-midy)*cos(angle) + midy;
delay(200);
cleardevice();
printf("Co-ordinates are: %f,%f",x1,y1);
 line(midx,midy,x1,y1);

 getch();
 closegraph();



}

No comments:

Post a Comment