more

1. added centre of (x,y) to make drawable visible
2. used actual length instead of unit length  xp=x+Math.sqrt(dx2*dx2+dy2*dy2)*Math.cos(Math.atan2(dy2,dx2)-Math.atan2(dy1,dx1))*Math.cos(Math.atan2(dy1,dx1)); // xp = x + component cta1
yp=y+Math.sqrt(dx2*dx2+dy2*dy2)*Math.cos(Math.atan2(dy2,dx2)-Math.atan2(dy1,dx1))*Math.sin(Math.atan2(dy1,dx1)); //
3. added
Rcos = R*Math.cos((Math.atan2(dy2,dx2)-Math.atan2(dy1,dx1)));
Rsin = R*Math.cos((Math.atan2(dy2,dx2)-Math.atan2(dy1,dx1)));
4. change the logic of drawing the angle polyon to
dc = (Math.atan2(dy2,dx2)-Math.atan2(dy1,dx1))/(n-2);// modify to draw from black line sing dx and dy as inputs
px[0]=x; // for drawing angle polygon
py[0]=y; //
for(int i=1;i  c=Math.atan2(dy2,dx2)-(i-1)*dc;  // modify to work drawing from black line
//  if(c<-pi)c+=2*pi; // no necessary
  px[i]=x+d*Math.cos(c); //
  py[i]=y+d*Math.sin(c); //
}
5. added functions to make slider draggable to control the graphics, thanks Prof Hwang!