:

## 3D implicit plot with scaled axes

Maple

Someone asked on math.stackexchange.com about plotting x*y*z=1 and, while it's easy enough to handle it with implicitplot3d it raised the question of how to get nice constained axes in the case that the x- or y-range is much less than the z-range.

Here's what WolframAlpha gives. (Mathematica handles it straight an an plot of the explict z=1/(x*y), which is interesting although I'm more interested here in axes scaling than in discontinuous 3D plots)

Here is the result of a call to implicitplot3d with default scaling=unconstrained. The axes appear like in a cube, each of equal "length". Here is the same plot, with scaling=constrained. This is not pretty, because the x- and y-range are much smalled than the z-range. How can we control the axes scaling? Resizing the inlined plot window with the mouse just affects the window. The plot itself remains  rendered in a cube. Using right-click menus to rescale just makes all axes grow or shrink together.

One unattractive approach it to force a small z-view on a plot of a much larger z-range, for a piecewise or procedure that is undefined outisde a specific range.

```plots:-implicitplot3d(proc(x,y,z)
if abs(z)>200 then undefined;
else x*y*z-1; end if;
end proc,
-1..1, -1..1, -200..200, view=[-1..1,-1..1,-400..400],
style=surfacecontour, grid=[30,30,30]);
``` Another approach is to scale the x and y variables, scale their ranges, and then force scaled tickmark values. Here is a rough procedure to automate such a thing. The basic idea is for it to accept the same kinds of arguments are implicitplot3d does, with two extra options for scaling the axis x-relative-to-z, and axis y-relative-to-z.

```implplot3d:=proc( expr,
rng1::name=range(numeric),
rng2::name=range(numeric),
rng3::name=range(numeric),
{scalex::numeric:=1, scaley::numeric:=1} )
local d1, d2, dz, n1, n2, r1, r2, rngs, scx, scy;
uses plotfn=plots:-implicitplot3d;
(n1,n2) := lhs(rng1), lhs(rng2);
dz := rhs(rhs(rng3))-lhs(rhs(rng3));
(scx,scy) := scalex*dz/(rhs(rhs(rng1))-lhs(rhs(rng1))),
scaley*dz/(rhs(rhs(rng2))-lhs(rhs(rng2)));
(r1,r2) := map(`*`,rhs(rng1),scx), map(`*`,rhs(rng2),scy);
(d1,d2) := rhs(r1)-lhs(r1), rhs(r1)-lhs(r1);
plotfn( subs([n1=n1/scx, n2=n2/scy], expr),
n1=r1, n2=r2, rng3, _rest[],
':-axis'=[':-tickmarks'=[seq(i=evalf(i/scx),i=r1,d1/4)]],
':-axis'=[':-tickmarks'=[seq(i=evalf(i/scy),i=r2,d2/4)]],
':-scaling'=':-constrained');
end proc:
```

The above could be better. It could also detect user-supplied custom x- or y-tickmarks and then scale those instead of forming new ones.

Here is an example of using it,

```implplot3d( x*y*z=1, x=-1..1, y=-1..1, z=-200..200, grid=[30,30,30],
scalex=1.618, scaley=1.618 );
``` Here is another example

```implplot3d( x*y*z=1, x=-5..13, y=-11..5, z=-200..200, grid=[30,30,30],
style=surfacecontour, orientation=[-50,55,0],
scaley=0.5 );
``` Ideally I would like to see the GUI handle all this, with say (two or three) additional (scalar) axis scaling properties in a PLOT3D structure. Barring that, one might ask whether a post-processing routine could use plots:-transform (or friend) and also force the tickmarks. For that I believe that picking off the effective x-, y-, and z-ranges is needed. That's not too hard for the result of a single call to the plot3d command. Where it could get difficult is in handling the result of plots:-display when fed a mix of several spacecurves, 3D implicit plots, and surfaces.

Have I overlooked something much easier?

acer ﻿