1
 2
 3  public class mirrorvisitor extends visitor
 4  {
 5      protected float a,b,c; // Hesse Normalform
 6      protected float norm, distance;
 7
 8      public mirrorvisitor(float x1,float y1, float x2, float y2)
 9      {
10
11          a=y1-y2;
12          b=x2-x1;
13          c=-(a*x1+b*y1);
14          norm=(float) Math.sqrt(a*a+b*b);
15          a/=norm;
16          b/=norm;
17          c/=norm;
18      }
19
20      public void visitPOINT   (point p)
21      {
22          distance=a*p.X+b*p.Y+c;
23          p.set(p.X-2*distance*a,p.Y-2*distance*b);
24      }
25
26      public void visitLINE    (line l)
27      {
28          l.Begin.receive(this);
29          l.End.receive(this);
30      }
31
32      public void visitCIRCLE (circle c)
33      {
34          c.Center.receive(this);
35      }
36  }