How to remove all elements from a dynamic two-dimensional array w

jospercomp shared this question 2 years ago
Answered

How to remove all the elements of a two-dimensional dynamic matrix without deleting the variable in order to create another dynamic matrix with the same variable but with another number of rows and columns because within the two-dimensional matrices there are undefined elements scattered?

Best Answer
photo

I have defined the mirror axis for l13 and l14 as line and inline (inside the command l13, l14)

Question: Does the applet work now? If NO: what is not OK?

If YES: I do not know why with certainty.

In your original version possibly the mirror axis (as segment) can be too short in length and/or possibly (but rather unlikely) the process of mirror axis is not finished at time of l13, l14.

Or something else mysterious.

Comments (11)

photo
1

supongo que con un setvalue(m1,zip(zip(m1(j,k),j,{1,3}),k,{2,3}) por ejemplo

un ejemplo más concreto con original y final sería util

photo
1

The real problem is that create a list in matrix form of n rows of reflections with m columns of segments if the segments are inside a triangle; but the problem is that the reflections disappear when I decrease the amount of reflections n in the regular polygon with respecto to apothem; if increase the amount of reflections more reflections appear without error. I thought it was a problem of the undefined objects that are outside the triangle but apparently it is not. I don't know why the reflections are not shown if I change the object of the reflection line between segment to straight line and vice versa, the reflections appear again regardless of the number of reflections that the variable n is.

https://www.geogebra.org/m/fnsvgagy

As if the Reflect command needs an UpdateConstruction command somewhere.

Segments of Reflection

Sequence(Segment((0, 0), Element(LPapo, i)), i, 1, Length(LPapo), 1)

Segments

LsegC=Sequence(If(IsInRegion(Element(LMS, i, 2), t1) ≟ true ∧ IsInRegion(Element(LMS, i, 3), t1) ≟ true, true), i, 1, nS, 1)

LsegR=Sequence(Sequence(If(Element(LsegC, i) ≟ true, Rotate(Element(LSeg, i), j (360°) / n)), i, 1, nS, 1), j, 1, n, 1)

LsegS=Sequence(Sequence(Reflect(Element(LsegR, i), Element(LSapo, j)), i, 1, Length(LsegR), 1), j, 1, n, 1)

Arcs

LArcC=Sequence(If(IsInRegion(Element(LMC, i, 2), t1) ≟ true ∧ IsInRegion(Element(LMC, i, 3), t1) ≟ true ∧ IsInRegion(Element(LMC, i, 4), t1) ≟ true, true), i, 1, 2, 1)

LArcR=Sequence(Sequence(If(Element(LArcC, i) ≟ true, Rotate(Element(LC, i), j (360°) / n)), i, 1, 2, 1), j, 1, n, 1)

LArcS=Sequence(Sequence(Reflect(Element(LArcR, i), Element(LSapo, j)), i, 1, Length(LArcR), 1), j, 1, n, 1)

photo
1

How to work this command? What is m1 object and value?

setvalue(m1,zip(zip(m1(j,k),j,{1,3}),k,{2,3})

photo
photo
2

the elements of a list must be all of same type. I think there is a problem with this

photo
1

It would be to rewrite these commands in some other way because if I exchange these two commands it is fixed.

LSapo=Sequence(Segment((0, 0), Element(LPapo, i)), i, 1, Length(LPapo), 1)

LSapo=Sequence(Line((0, 0), Element(LPapo, i)), i, 1, Length(LPapo), 1)

//////////////////////////////////////////////////

LsegS=Sequence(Sequence(Reflect(Element(LsegR, i), Element(LSapo, j)), i, 1, Length(LsegR), 1), j, 1, n, 1)

LArcS=Sequence(Sequence(Reflect(Element(LArcR, i), Element(LSapo, j)), i, 1, Length(LArcR), 1), j, 1, n, 1)

photo
photo
2

the elements of a list must be all of same type. I think there is a problem with this

is correct, you are mixing element types in your lists:


{{p, F, G, H}, {q, K, J, I}}

photo
1

I have already separated the objects from the points into two different lists; but all the error of reflection continues.

photo
photo
1

I have defined the mirror axis for l13 and l14 as line and inline (inside the command l13, l14)

Question: Does the applet work now? If NO: what is not OK?

If YES: I do not know why with certainty.

In your original version possibly the mirror axis (as segment) can be too short in length and/or possibly (but rather unlikely) the process of mirror axis is not finished at time of l13, l14.

Or something else mysterious.

photo
1

Thank you very much the program is working now. I like finding bugs and mysterious solutions because larger programs turn into applications that you want to make similar to this one. It would be nice to make a web page of repository of mysterious errors in the commands or in the script.

photo
1

The problem of the reflection command seems to be that the Line or Segment commands must always be nested inside the reflection command, otherwise the reflection line is disconnected from the command and does not produce the reflection of the object. They should put a clarifying note about that debug in the reflect command.

https://wiki.geogebra.org/e...

photo
1

Line or Segment commands must always be nested inside the reflection command

Sorry, I don't know what you mean by this. Please post a minimal .ggb file

photo
© 2023 International GeoGebra Institute