Creating polygons using sequence

Kristy shared this question 3 years ago
Answered

I made some polygons using the sequence function

Sequence(Polygon((2k, 0), (2k + 1, 0), (2k + 1, 10), (2k, 10)), k, 0, Tens - 1)

while Tens is a integer slider.

When Tens=1, only one polygon will show (i.e. the leftmost one).

The picture below shows Tens=6

bf5e588174defd379f100e07bb53f3f6

Actually I would like to divide each polygon into 10 smaller pieces (just to add lines like the leftmost polygon)

I used sequence command to create those lines.

Sequence(Segment((0, k), 1), k, 1, 9)

but this command only apply to the leftmost polygon.

Therefore, I would like to ask how should I do in order to create the segments for the other polygons?

Comments (2)

photo
1

Sequences can be nested.

Take your first sequence without the expression for the polygon.


  • Sequence(.......................................................................... , k, 0, Tens - 1)

and replace the polygon-expression with your second sequence.

But this so that there are different indexes for both sequences (i and k).

Use these two indexes for the segment command.


  • Sequence(Sequence(Segment((2k, i), 1), i, 1, 9), k, 0, Tens - 1)

.

Note: The above syntax for the segment does not work in GGB5.0

The following syntax would probably be better

  • Sequence(Sequence(Segment((2k, i), (2k + 1, i)), i, 1, 9), k, 0, Tens - 1)

---------------------------------------------------------------------------------

Alternative:

Create squares instead of segments in the nested sequence (and delete your first sequence).

-----------------------------------------------------------------------------------

Note:

It is easier for me (and also for you) if you only use the object names instead of the written commands and attach the current status of your application as a GGB file.

photo
1

with squares, expanded

© 2023 International GeoGebra Institute