Demo entry 6749007

Calculation of XY offset

   

Submitted by anonymous on Jun 11, 2018 at 15:46
Language: C. Code size: 463 Bytes.

s8 move_deltaxy(double deltax,double deltay,int speed){
	double x,y;
	x=-L1*cos(get_angle(0)*PI/180)+L2*cos(get_angle(1)*PI/180);
	y=L1*sin(get_angle(0)*PI/180)+L2*sin(-get_angle(1)*PI/180);
	x=x+deltax;
	y=y+deltay;
	if((x*x+y*y)>(L1+L1)*(L1+L2)){
		if(deltax==0)
			y=sqrt((L1+L1)*(L1+L2)-x*x);
		else if(deltay==0)
			x=sqrt((L1+L1)*(L1+L2)-y*y);
	}//计算出不可实现位置
	printf("get0=%f,get1=%f\n",get_angle(0),get_angle(1));
	return move_xy(x,y,speed);
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).