# Annotating multiple angles via GGB script

johnbmaths shared this question 2 years ago

To explain simply part of a more complex project I have say two groups of 3 points A,B,C and D,E,F and essentially wish to mark the angles ABC, DEF with the angle values via script. Code can be called say from a button.

This simple example can be hard coded as in the first method but is of course tedious for multiple angles.

points={{A,B,C},{D,E,F}}

# This works but is tedious for more than 2 sets of points

Angle(points(1,1),points(1,2),points(1,3))

Angle(points(2,1),points(2,2),points(2,3))

# Because of the way Geogebra scripts work this next attempt only here for illustrative purposes simply duplicates the second point as k is set to 2 on before the angles are evaluated

k=1

Angle(points(k,1),points(k,2),points(k,3))

k=2

Angle(points(k,1),points(k,2),points(k,3))

# So need a loop. This attempt lumps the 2 output angles together in a sequence and doesn't achieve what is needed.

Sequence(Angle(points(k,1),points(k,2),points(k,3)),k,1,2)

Could anyone suggest how the 3rd method or equivalent can be amended to produce the required result?

Also would like to be able to get the point objects from a list.

For example points(1,1) gives the coords of the point named A and not A which I would like to understand how to do.

I also cannot figure how to produce a list like {{A,B,C},{D,E,F} from 2 lists {A,B,C} and {D,E,F}. Whatever I have tried simply gives coordinate lists and not object lists.

Any help with 1 or all of these 3 queries much appreciated.

1

attached a sample with Execute()

1

Thank you Rami for taking the time to provide a solution using Execute which works fine.

However it is a hard coded solution which essentially requires each angle being referenced pretty much as my suggested initial attempt with just 2 angles for illustration.

For shapes with multiple angles this is mega tedious and any alteration to the project requires altering the code as well.

That is the problem with GGB scripting - the lack of decent loops.

I decided to use Javascript and the loop structures there make the problem much more tractable.

I would still like to know how to join object lists {A,B,C} and {D,E,F} to produce {{A,B,C},{D,E,F}} as objects rather than evaluated coordinate lists.

1

questions:

1) What are the object names of {A,B,C}, {D,E,F}....{P_1,P_2,P_3} ???

For example aP_{n} or similar?

2) Who creates these objects, who determines the direction of rotation, who determines the name and how???

The same question would arise when using JS. (what I do not recommend, especially the handling of GGB-lists is a "bit" difficult in JS)

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

The context of the question is very broadly worded. a full example showing the interactive dynamics would be helpful to give a good answer.

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

By the way, the following option might be exactly what you are looking for

If your shapes are polygons, then clicking with the "Angle tool" on the face of the polygon. This will create all the interior angles. Or write as new objects in the input-line (or script):

Angle(<polygon-name>) AND/OR {Angle(<polygon-name>)}

1

The example I cite Rami has Point objects A,B,C D, E, F. Created if you like manually by the Point tool. This is entirely unrelated to anything to do with angles it is simply a generic question re GeoGebra lists/commands. By their nature questions on GGB list commands and their utility are "broad". How do you produce a list of object names {{A,B,C},{D,E,F}} from 2 lists of already named objects {A,B,C} and {D,E,F} lets say for simplicity all are Point objects. I can handle where they come from and what to do with them and how they are named. I am able to produce coordinate lists for the above Point examples with no problem but NOT object lists which purely for intellectual purposes I would like to know how to do. That was my question. I can do it in JS very simply but not in GGB script.

The same question does not arise in JS within which which I can handle most things comfortably. I really fail to understand why there are so many comments on this forum discouraging use of JS as opposed to GGB script as opposed to don't use any scripts at all. I would humbly suggest that JS is a far better environment to work with and I can pretty much do whatever I wish there. The links to GGB from JS seem sufficient currently to do most things although I have not tested thoroughly for reliability.

To be frank GGB script is quite awful and users would be far better directed away from that rather than from JS. Its handling of variables and lack of ability to provide almost any of the basic unctions of a scripting language makes it pretty unusable for me except for very limited usage. GGB script's lack of basic scripting facilities forces tedious hard coding which for me is anathema.

Thanks for your interest and suggestions Rami.The last one re Polygon I am aware of and can indeed be useful to me. Thank you.