1 public class rotatevisitor extends visitor
2 {
3 protected point Center;
4 protected point RelativeBefore;
5 protected point RelativeAfter;
6 protected float sinAlpha,cosAlpha;
7
8 public rotatevisitor(float x,float y, float a)
9 {
10 Center=new point(x,y);
11 RelativeBefore=new point(0,0);
12 RelativeAfter=new point(0,0);
13 sinAlpha=(float) Math.sin(a);
14 cosAlpha=(float) Math.cos(a);
15 }
16
17 public void visitPOINT (point p)
18 {
19 RelativeBefore.X=p.X-Center.X;
20 RelativeBefore.Y=p.Y-Center.Y;
21
22 RelativeAfter.X=cosAlpha*RelativeBefore.X-sinAlpha*RelativeBefore.Y;
23 RelativeAfter.Y=sinAlpha*RelativeBefore.X+cosAlpha*RelativeBefore.Y;
24
25 p.set(RelativeAfter.X+Center.X,RelativeAfter.Y+Center.Y);
26 }
27
28 public void visitLINE (line l)
29 {
30 l.Begin.receive(this);
31 l.End.receive(this);
32 }
33
34 public void visitCIRCLE (circle c)
35 {
36 c.Center.receive(this);
37 }
38 }