Reflection of a circular wave-front

Example from the PscFunctions package

With the help of routines of the PscFunctions package   it is possible to transform equations of curves and surfaces .
Let the curve is given by the parametric equation
x=x(t), y=y(t) . Then the equation of the curve obtained by multiple interior reflection from boundaries of the rectangle region xl<x<xr, yd<y<yu  looks like the following:

x = x[l]+stc(x(t)-x[l],2*(x[r]-x[l])) ,             (1)
y = y[d]+stc(y(t)-y[d],2*(y[u]-y[d])) ,           (2)

where stc(x,w)  is a sawtooth function from the PscFunctions  package.
At any moment the circular wave-front advancing from the point it is possible to transform by formulas (1), (2). As a result we shall obtain the parametric equation of its shape after reflection from boundaries of the rectangular region. In the next example the advancing and reflection process of a circular wave-front inside a square is shown. The starting point is located at the centre.

>    restart;
with(PscFunctions):
xl:=-1: xr:=1: yd:=-1: yu:=1:  # reflection boundary
x:=a->t*cos(a):
y:=a->t*sin(a):
# equation of the reflected wave-front
xw:=a->xl+stc(x(a)-xl,2*(xr-xl)):
yw:=a->yd+stc(y(a)-yd,2*(yu-yd)):
plots[animate](plot,[[xw(a),yw(a),a=0..2*Pi],color=BLACK],t=0..6,scaling=CONSTRAINED,thickness=2,frames=31);

[Maple Plot]

In the next example the wave-front goes out the point (x0, y0) of a square region . At sufficiently large time the curve paint over the most of the square area.

>    xl:=-1: xr:=1: yd:=-1: yu:=1:  # reflection boundary
c:=1: a:='a':
x0:=1/2: y0:=0:
x:=(t,a)->x0+c*t*cos(a):
y:=(t,a)->y0+c*t*sin(a):
xw:=(t,a)->xl+stc(x(t,a)-xl,2*(xr-xl)):
yw:=(t,a)->yd+stc(y(t,a)-yd,2*(yu-yd)):
t1:=40.1:       # epoch of observation
plot([xw(t1,a),yw(t1,a),a=0..2*Pi],-1..1,-1..1,color=BLACK,numpoints=5000,thickness=1,scaling=CONSTRAINED);

[Maple Plot]

The represented figure is painted by a curve in the fixed point of time t . It was created by the following parametric equation

>    'xw'=xw('t','alpha');
'yw'=yw('t','alpha');

xw = -1+stc(3/2+t*cos(alpha),4)
yw = -1+stc(t*sin(alpha)+1,4)