2
$\begingroup$

I have a method to plot a rectangular region and then plot the lattice transformation by some complex function $f[z]$.

latticeTransform[f_: Function, xrange_: Range, yrange_: Range] :=
  (curve = Graphics[BezierCurve[RandomPoint[
       Rectangle[{xrange[[2]], yrange[[2]]}, {xrange[[3]],yrange[[3]]}], 6]]];
   dom = Show[{ParametricPlot[{x, y}, xrange, yrange, 
       AspectRatio -> 1], curve}]; 
   image = ParametricPlot[{Re[f[z]], Im[f[z]]} /. z -> x + I*y, xrange, 
     yrange, PlotRange -> All];
   GraphicsGrid[{{dom, image}}, ImageSize -> Large]);

I added the Bézier curve to visualize how a random curve will get transformed in the output, but I'm not entirely sure how to map it onto the image. I thought about storing the random points I generated, transforming them with $f[z]$, and then calling BezierCurve[] on the points again, but I believe this wouldn't be a true mapping as Bézier will recalculate and find a new curve.

Is this correct? If so, how would I draw the curve transformed by $f[z]$?

Edit: My only other thought is to get a list of points {x, y} on the Bézier curve and generate a new list by f[x + I y], but again I'm unsure of how to do this and it has a tradeoff of accuracy vs. computation time.

$\endgroup$
  • $\begingroup$ A Bézier curve after an arbitrary complex transformation will of course not necessarily be a Bézier curve anymore. $\endgroup$ – J. M. will be back soon Jul 26 '17 at 12:49
  • 3
    $\begingroup$ Counter example : A exact circle can't be represented with a Bezier curve, though it is the transformation of a straight line by a complex function. $\endgroup$ – andre314 Jul 26 '17 at 12:51
  • $\begingroup$ @J.M. thanks, so I can't just call Bezier curve again. But how would I transform the curve by the function? I'm more interested in mapping the curve than the semantics of a Bezier. $\endgroup$ – Dando18 Jul 26 '17 at 13:02
5
$\begingroup$

You'll need to work a bit harder to demonstrate the complex transformation of a Bézier curve; in particular, you need to express the curve explicitly in terms of the Bernstein basis before transforming. Here's an example:

BlockRandom[SeedRandom["bezier"]; (* for reproducibility *)
 With[{f = Function[x, ArcTan[x]], xrange = {-5, 5}, yrange = {-4, 4}},

      (* generate random Bézier curve explicitly *)
      pts = RescalingTransform[{{0, 1}, {0, 1}}, {xrange, yrange}] @ RandomReal[1, {6, 2}];
      n = Length[pts] - 1;
      {bf[t_], bg[t_]} = BernsteinBasis[n, Range[0, n], t].pts;

      GraphicsRow[{Show[ParametricPlot[{x, y}, Prepend[xrange, x] // Evaluate, 
                                       Prepend[yrange, y] // Evaluate,
                                       AspectRatio -> Automatic, Mesh -> True,
                                       PlotStyle -> None], 
                        ParametricPlot[{bf[t], bg[t]}, {t, 0, 1}]], 
                   Show[ParametricPlot[ReIm[f[x + I y]], Prepend[xrange, x] // Evaluate,
                                       Prepend[yrange, y] // Evaluate, 
                                       AspectRatio -> Automatic, Mesh -> True,
                                       PlotStyle -> None], 
                        ParametricPlot[ReIm[f[bf[t] + I bg[t]]], {t, 0, 1}]]}]]]

mesh and Bézier curve, pre- and post-transformation

Turning the entire business into a suitable Manipulate[] is left as an exercise for the interested reader.

$\endgroup$
  • $\begingroup$ Thanks! I'll have to read up on the Bernstein basis. Would you happen to have a recommendation on a cleaner way to generate a random curve and transform it? maybe without Béziers? $\endgroup$ – Dando18 Jul 26 '17 at 13:16
  • 1
    $\begingroup$ Your "and transform it" is the source of the complication in this case. Some math to ponder: Bézier curves (and more generally B-spline curves) only remain as such under an affine transformation, and such transformations can be done easily by transforming only the control points instead of the entire curve. $\endgroup$ – J. M. will be back soon Jul 26 '17 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.