## CNC to Robot

Before anything else, sorry for my english, may not be the better.

I'm making a program in C++, that makes the translation of Gcodes to a Robot language (my case Rapid, from ABB).

In linear moves i got no problems, i got the actual point and the next point and it's a simply move... or i got the origin and the destination point.

But in circular moves the Gcodes are different.

Gcode give me the center of the circle (C) and the destination (B) point (i got the actual point (A))... and give me the direction (clock side or anticlock side, G02 or G03).
But the Robot need's a point in the trajectory of the movement from the actual point to the destination point (the point D or F).

The question, i make some functions, and i have that tow points (E and F) but with the information of the side (clock or anti clock) how can i decide (in conditions if, else...) what is the point that i want...

the code i have...

int i; // "coord_D" ponto medio 'D' da linha recta do pt inicial 'A' ao final 'B'
float coord_D[3],vector_CD[3],vector_CA[3],coord_E[3],versor_CD[3],coord_F[3]; //"vector_CD" vector do centro ao ponto D
float norma_CD,raio; //"vector_CA" vector do centro ao ponto inicial 'A'
//"coord_E" coordenadas ponto medio 'E' da linha curva do pt 'A' ao 'B'
clrscr(); //"coord_F" coordenadas ponto medio 'F', que é oposto ao pt 'E'
for(i=0;i<2;i++) {
printf("\nponto A = %.3f",coord_movc[0].inicial[i]);
}
for(i=0;i<2;i++) {
printf("\nponto B = %.3f",coord_movc[0].final[i]);
}
for(i=0;i<2;i++) {
printf("\nCentro = %.3f",coord_movc[0].centro[i]);
}
coord_D[0]=(coord_movc[0].final[0]+coord_movc[0].inicial[0])/2;
coord_D[1]=(coord_movc[0].final[1]+coord_movc[0].inicial[1])/2;
coord_D[2]=(coord_movc[0].final[2]+coord_movc[0].inicial[2])/2;

printf("\n\n\n ponto D = (%f;%f;%f)",coord_D[0],coord_D[1],coord_D[2]);

vector_CD[0]=coord_D[0]-coord_movc[0].centro[0]; //calculo do vector CD
vector_CD[1]=coord_D[1]-coord_movc[0].centro[1];
vector_CD[2]=coord_D[2]-coord_movc[0].centro[2];

norma_CD= sqrt(pow(vector_CD[0],2) + pow(vector_CD[1],2) ); //calculo da norma do CD positiva

printf("\n\nnorma CD = %f",norma_CD);
if (norma_CD==0){
printf("\nERRO\n");
getch();
return;
}
versor_CD[0] = vector_CD[0]/norma_CD; // calculo do versor de CD
versor_CD[1] = vector_CD[1]/norma_CD;
versor_CD[2] = vector_CD[2]/norma_CD;
printf("\n\nversor = (%f;%f;%f)",versor_CD[0],versor_CD[1],versor_CD[2]);
vector_CA[0]=coord_movc[0].inicial[0]-coord_movc[0].centro[0]; // calculo do raio
vector_CA[1]=coord_movc[0].inicial[1]-coord_movc[0].centro[1];
vector_CA[2]=coord_movc[0].inicial[2]-coord_movc[0].centro[2];
raio = sqrt(pow(vector_CA[0],2) + pow(vector_CA[1],2) );
printf("\n\n\nraio = %f",raio);

coord_E[0]= versor_CD[0]*raio; // calculo ponto 'E'
coord_E[1]= versor_CD[1]*raio;
coord_E[2]= versor_CD[2]*raio;
printf("\n\n\nponto E = (%f;%f;%f)",coord_E[0],coord_E[1],coord_E[2]);

coord_F[0]= -versor_CD[0]*raio; //calculo do ponto,'F', oposto ao 'E'
coord_F[1]= -versor_CD[1]*raio;
coord_F[2]= -versor_CD[2]*raio;

printf("\n\n\nponto F = (%3.3f;%3.3f;%3.3f)",coord_F[0],coord_F[1],coord_F[2]);