# Plotting the deformed shape of a rectangle

I want to plot a rectangle using graphics :

rc = Graphics[{Blue, Rectangle[{0, 0}, {1, 1}]}];


and add a deformation function to it:

$$\chi(\mathbf X)=X_1(1+X_2)\hat{\mathbf e}_1+X_2(1+3X_1)\hat{\mathbf e}_2$$

This deformation function specifies new coordinates as functions of old ones. How can I plot the new shape?

• Have you looked at this in the documentation? Commented Jun 12, 2013 at 6:16
• @m_goldberg, seeing as the deformation is of the three-dimensional sort, Graphics[] won't help the OP. Graphics3D[] might...maybe even ParametricPlot3D[]. Commented Jun 12, 2013 at 6:17
• @J. M. The reference I gave gives information on and further links to both 2D and 3D transforms. Commented Jun 12, 2013 at 6:21
• In that case, ponder upon the result of {ParametricPlot[{u, v}, {u, 0, 1}, {v, 0, 1}], ParametricPlot[{u (1 + v), v (1 + 3 u)}, {u, 0, 1}, {v, 0, 1}]} // GraphicsRow. Commented Jun 12, 2013 at 6:31
• If you understood how ParametricPlot[] worked in that snippet I posted, may I suggest writing an answer to your own question, so that we can gauge your understanding of that solution? Commented Jun 12, 2013 at 6:56

As J. M. suggested in comments, ParametricPlot[] can be used to show this deformation:

{ParametricPlot[{u, v}, {u, 0, 1}, {v, 0, 1}],
ParametricPlot[{u (1 + v), v (1 + 3 u)}, {u, 0, 1}, {v, 0,1}]} // GraphicsRow


• Looks right, but the setting AspectRatio -> 1 will of course necessarily distort your region further. Someone looking at the pictures should then be careful to note that the scales on the axes in the picture on the left and the picture on the right are different. Commented Jun 12, 2013 at 7:25

Another way of approaching this is to map the image of the rectangle rather than the geometric object itself.

img = Image[Graphics[{Blue, Rectangle[{0, 0}, {1, 1}]}]]


This turns the graphic into an image which can then be mapped using the specified function:

ImageForwardTransformation[img, {#[[1]] (1 + #[[2]])/4, #[[2]] (1 + 3 #[[1]])/4} &]


The only wrinkle here is that the range of the image needs to be in {0,1} so I scaled both entries by the largest value (4) so that would show the whole image of the distorted rectangle.

Of course, this method maps not only the rectangle itself, but also the contents of the rectangle (if any). So for example, the same mapping can be applied to an image.

img = Import["https://i.sstatic.net/6zVEI.png"];


ImageForwardTransformation[img, {#[[1]] (#[[2]] + 1)/4,
(1 + 3 #[[1]]) #[[2]]/4} &, Background -> White]


• Alternatively: ImageForwardTransformation[Image[Graphics[{Blue, Rectangle[{0, 0}, {1, 1}]}, ImagePadding -> None, PlotRangePadding -> None]], # ({#[[2]], 3 #[[1]]} + 1) &, Background -> 1., DataRange -> {{0, 1}, {0, 1}}, PlotRange -> {{0, 2}, {0, 4}}]. Commented Jun 12, 2013 at 9:14