# How to rescale a NDSolve curve to fit in a box?

I'm numerically solving some differential equations and the 3D curve I get has a very complicated shape and size that cannot be predicted from the initial conditions.

I need to rescale the whole curve to fit it entirely inside the cube defined below. As a simple example, lets say the curve is this one (the real curve is much more complicated than that, and strongly depends on the initial conditions !) :

curve = ParametricPlot3D[
{0.2 t (Sin[3 t] - 2), 0.2 t (Cos[5 t] + 1), t},
{t, 0, 2Pi},
Boxed -> True,
PlotRange -> All,
Axes -> True,
AxesOrigin -> {0, 0, 0}
]


Now, I would like to rescale the whole curve so it fits entirely inside a centered cube of size 10 :

cube = Graphics3D[{Opacity[0.2], Cuboid[{-5, -5, -5}, {5, 5, 5}]}];

Show[{curve, cube},
Axes -> True,
AxesOrigin -> {0, 0, 0},
Method -> {"RotationControl" -> "Globe"},
ImageSize -> {700, 700}
]


Take note that the curve is starting at the origin : {0, 0, 0}, and should still be starting at that same point after rescaling.

How can I do that rescaling ?

Just in case this is important : the real curve would be shown with a Manipulate code, to change the initial conditions. When I change these, the curve's shape and size change accordingly, but it still need to be rescaled to fit inside the same cube.

Try this:

  tab = Transpose[
Table[{0.2 t (Sin[3 t] - 2), 0.2 t (Cos[5 t] + 1), t}, {t, 0, 2 Pi,
0.001}]];
maxX = Max[{Abs[Min[tab[]]], Abs[Max[tab[]]]}];
maxY = Max[{Abs[Min[tab[]]], Abs[Max[tab[]]]}];
maxZ = Max[{Abs[Min[tab[]]], Abs[Max[tab[]]]}];
sc = 5*{1/maxX, 1/maxY, 1/maxZ};
Show[{Graphics3D[{Opacity[0.2], Cuboid[{-5, -5, -5}, {5, 5, 5}]}],

ParametricPlot3D[{0.2 t (Sin[3 t] - 2), 0.2 t (Cos[5 t] + 1), t}*
sc, {t, 0, 2 Pi}, Boxed -> True, PlotRange -> All, Axes -> True,
AxesOrigin -> {0, 0, 0}]
}] Have fun!

• It's working. I'll study this answer. Thanks a lot ! – Cham Mar 26 '16 at 15:38