Game:点关于点的旋转。
pascal吧
全部回复
仅看楼主
level 10
LJ37NX 楼主
Procedure Rotation(var a,b:longint,x,y,n:longint,d:boolean);
Label
1,2,3,4,5,6; //标记
Var
Time,times,c,e,f,r:longint;
k:real;
Begin
R:=int(sqrt((x-a)*(x-a)+(y-b)*(y-b)));
Time:=4*r+2;
K:=n/360;
Times:=int(time*k);
If d=true then begin
1:
If b>y then
If a-times<x-r then
Begin
Times:=times-(a-x+r);
B:=y;
A:=x-r;
Goto 1;
End else
Begin
2:
A:=a-times;
B:=y+int(sqrt(r*r-(a-x)*(a-x)));
Exit;
End;
If b=y then
If a>x then goto 2 else goto3;
If b<y then
If a+times >x+r then
Begin
Times:=times-(x+r-a);
B:=y;
A:=x+r;
Goto 1;
End else
Begin
3:
A:=a+times;
B:=y-int(sqrt(r*r-(a-x)*(a-x)));
Exit;
End;
End;
If d=false then
Begin
4:
If b>y then
If a+tims>x+r then
Begin
Times:=times-(x+r-a);
B:=y;
A:=x+r;
Goto 4;
End else
Begin
5:
A:=a+times;
B:=y+int(sqrt(r*r-(a-x)*(a-x)));
Exit;
End;
If b=y then
If a>x then goto 6 else goto 5;
If b<y then
If a-times<x-r then
Begin
Times:=times-(a-x+r);
B:=y;
A:=x-r;
Goto 4;
End else
Begin
6:
A:=a-times;
B:=y-int(sqrt(r*r-(x-a)*(x-a)));
Exit;
End;
End;
End;
2015年04月18日 15点04分 1
level 10
LJ37NX 楼主
Int是一个四舍五入的函数,可以用trunc代替,但会导致不精确。
2015年04月18日 15点04分 2
level 10
LJ37NX 楼主
手机打,可能代码有些问题。
2015年04月18日 15点04分 3
level 10
LJ37NX 楼主
Ture 是顺时针。
2015年04月18日 15点04分 5
level 10
LJ37NX 楼主
可以用来在graph中做一些游戏(偏向于动态)面关于点的旋转代码可以以此为基础。但不是简单的多次使用。
2015年04月18日 15点04分 6
level 10
LJ37NX 楼主
没人么?
2015年04月18日 22点04分 7
level 12
Lz学好三角函数再来写会更加简单...不用分很多情况了
2015年04月19日 10点04分 8
level 10
LJ37NX 楼主
想过三角函数,但是要分情况(我朋友推的,你有没有更好的方法?)
2015年04月21日 09点04分 9
level 1

2015年04月26日 13点04分 10
1