Question: Why do piecewise and transform produce different plots of a truncated sphere?

The piecewise plot below displays a sphere truncated by the plane z = 2 - y.

f := proc (x, y, z) options operator, arrow; piecewise(z <= 2-y, x^2+y^2+z^2-16, z-2+y) end proc; implicitplot3d(f, -4 .. 4, -4 .. 4, -4 .. 4, style = surface, numpoints = 50000);

The 3 transforms below when executed in display(T(sphere([0, 0, 0], 4, numpoints = 50000)), scaling = constrained) display the truncated sphere differently:

1) the truncating plane only partly conforms to the boundary of the truncated sphere

2) the truncated sphere is correct provided that the else condition coordinate is in the truncating plane and truncated sphere

3) the truncated sphere is correct but hollow

 

1) T := transform(proc (x, y, z) options operator, arrow; `if`(z <= 2-y, [x, y, z], [x, y, 2-y]) end proc)

2) T := transform(proc (x, y, z) options operator, arrow; `if`(z <= 2-y, [x, y, z], [0, 0, 2]) end proc)

3) T := transform(proc (x, y, z) options operator, arrow; `if`(z <= 2-y, [x, y, z], [`&+-`(sqrt(16-y^2-z^2)), y, 2-y]) end proc)

Please explain the different behavior of the three transforms.           

Please Wait...