Write a function that creates a new figure (a new broken line) out of a given broken line. It would take as parameter a list of (max) 20 points representing the closed broken line. The output must be a plot with the two figures in different colors.

The new figure is created by connecting midpoints of consecutive segments of the figure.

Suggestion. Keep the coordinates of the randomly generated points in a symmetrical interval, for simplicity.

Observation. A closed broken line is a figure made of segments such that each segment's left endpoint is connected to another segment's right endpoint.

Given four points, the output should be similar to this:

enter image description here

  • 1
    $\begingroup$ What have you tried? This looks like a homework problem and we generally like to see what you've tried before we try to help. $\endgroup$ – b3m2a1 Mar 28 '19 at 18:19
  • $\begingroup$ ListLinePlot might be of interest. $\endgroup$ – Henrik Schumacher Mar 28 '19 at 18:23
  • 1
    $\begingroup$ @HighPerformanceMark before the edit it was $\endgroup$ – b3m2a1 Mar 28 '19 at 21:13
  • $\begingroup$ This is not a do-my-homework site. $\endgroup$ – Daniel Lichtblau Mar 29 '19 at 15:43

I would typically not answer this kind of questions, but this was interesting to me:

BlockRandom[SeedRandom[5348]; pts = RandomReal[{-2, 2}, {4, 2}]];

    EdgeForm[{Thick, Blue}], Polygon[pts],
    EdgeForm[{Thick, Red}], Polygon[Mean /@ Partition[pts, 2, 1, {1, 1}]]
  Axes -> True

Mathematica graphics

| improve this answer | |
  • $\begingroup$ Usually, I use ListCorrelate[] instead of Mean[] + Partition[], but this works. $\endgroup$ – J. M.'s technical difficulties Mar 29 '19 at 1:13

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