Clipping of surfaces

Example from the PscFunctions package

Using routines of the PscFunctions package it is possible to execute transformation of equations of surfaces.
Here we give some examples of clipping of surfaces. Let's create a surface .

>    restart;
with(PscFunctions):
f:=(x,y)->3/(1+x^2+y^2):
plot3d(f(x,y),x=-2..2,y=-2..2,axes=boxed);

[Maple Plot]

Using the base routines QL ,  QR and  PR of the package it is possible to create a parametric equation of a clipped  surface.
Let us  cut off the surface from two sides along the curves f0(x) and f1(x).

>    f0:=t->-1-sqrt(1-(-1+2*PR(t,-1,2))^2):
f1:=t->1+sqrt(1-(-1+2*PR(t,-1,2))^2):
plot({f0(x),f1(x)},x=-2..2,thickness=3,scaling=CONSTRAINED,color=black);

[Maple Plot]

>    dlt:=1:  # increment of parameter along a vertical shear
x:=(u,v)->QL(u,f0(v)-dlt)+f0(v)+(f1(v)-f0(v))*\
PR(u,f0(v),f1(v)-f0(v))+QR(u,f1(v)+dlt):
y:=(u,v)->v:
z:=(u,v)->f(f0(v)+(f1(v)-f0(v))*PR(u,f0(v),f1(v)-f0(v)),v)-\
f(f0(v),v)*(1-PR(u,f0(v)-dlt,dlt))-f(f1(v),v)*PR(u,f1(v),dlt):
plot3d([x(u,v),y(u,v),z(u,v)],u=-3..3,v=-2..2,scaling=CONSTRAINED,axes=BOXED,grid=[37,25],shading=ZHUE);

[Maple Plot]

The SCone  routine generates a parametric equation of a cone surface or a cylinder (a surface with bases). Using equation of the cylinder surface we can obtain a parametric equation of the truncated cylinder. To clipping a parametric surface by oblique plane  it is possible to use PscMax ,  PscMin ,  PscMinMax  routines of the package.

>    cl:=SCone(2,1,1):
Zplane:=(x,y)->x/2-y/2+4/3: # equation of truncating plane
x:=(u,v)->cl[1](u,v):
y:=(u,v)->cl[2](u,v):
z:=(u,v)->PscMin(cl[3](u,v),Zplane(x(u,v),y(u,v))):
plot3d([x(u,v),y(u,v),z(u,v)],u=0..2*Pi,v=0..4,scaling=CONSTRAINED,grid=[21,21],axes=BOXED);

[Maple Plot]

Here is the equation of the surface.

>    'X'=x(u,v);
'Y'=y(u,v);
'Z'=z(u,v);

X = (-1/2*abs(v)+1/2*abs(v-1)+1/2*abs(v-3)-1/2*abs(v-4))*cos(1/2*abs(u)-1/2*abs(u-2*Pi))
Y = (-1/2*abs(v)+1/2*abs(v-1)+1/2*abs(v-3)-1/2*abs(v-4))*sin(1/2*abs(u)-1/2*abs(u-2*Pi))
Z = 7/6+1/4*abs(v-1)-1/4*abs(v-3)+1/4*(-1/2*abs(v)+1/2*abs(v-1)+1/2*abs(v-3)-1/2*abs(v-4))*cos(1/2*abs(u)-1/2*abs(u-2*Pi))-1/4*(-1/2*abs(v)+1/2*abs(v-1)+1/2*abs(v-3)-1/2*abs(v-4))*sin(1/2*abs(u)-1/2*ab...
Z = 7/6+1/4*abs(v-1)-1/4*abs(v-3)+1/4*(-1/2*abs(v)+1/2*abs(v-1)+1/2*abs(v-3)-1/2*abs(v-4))*cos(1/2*abs(u)-1/2*abs(u-2*Pi))-1/4*(-1/2*abs(v)+1/2*abs(v-1)+1/2*abs(v-3)-1/2*abs(v-4))*sin(1/2*abs(u)-1/2*ab...
Z = 7/6+1/4*abs(v-1)-1/4*abs(v-3)+1/4*(-1/2*abs(v)+1/2*abs(v-1)+1/2*abs(v-3)-1/2*abs(v-4))*cos(1/2*abs(u)-1/2*abs(u-2*Pi))-1/4*(-1/2*abs(v)+1/2*abs(v-1)+1/2*abs(v-3)-1/2*abs(v-4))*sin(1/2*abs(u)-1/2*ab...
Z = 7/6+1/4*abs(v-1)-1/4*abs(v-3)+1/4*(-1/2*abs(v)+1/2*abs(v-1)+1/2*abs(v-3)-1/2*abs(v-4))*cos(1/2*abs(u)-1/2*abs(u-2*Pi))-1/4*(-1/2*abs(v)+1/2*abs(v-1)+1/2*abs(v-3)-1/2*abs(v-4))*sin(1/2*abs(u)-1/2*ab...

Here is the equation of the sphere clipped from different sides.

>    xs:=(R,phi,theta)->R*cos(phi)*cos(theta):
ys:=(R,phi,theta)->R*sin(phi)*cos(theta):
zs:=(R,phi,theta)->R*sin(theta):
X:=(u,v)->PscMinMax(xs(1,u,v),-3/4,3/4):
Y:=(u,v)->PscMinMax(ys(1,u,v),-3/4,3/4):
Z:=(u,v)->PscMinMax(zs(1,u,v),-3/4,3/4):
plot3d([X(u,v),Y(u,v),Z(u,v)],u=0..2*Pi,v=-Pi/2..Pi/2,scaling=CONSTRAINED,axes=BOXED,grid=[36,22]);
'X'=X(u,v);
'Y'=Y(u,v);
'Z'=Z(u,v);

[Maple Plot]

X = 1/2*abs(cos(u)*cos(v)+3/4)-1/2*abs(cos(u)*cos(v)-3/4)
Y = 1/2*abs(sin(u)*cos(v)+3/4)-1/2*abs(sin(u)*cos(v)-3/4)
Z = 1/2*abs(sin(v)+3/4)-1/2*abs(sin(v)-3/4)