Page 1 of 1
revRotatePoly
Posted: Fri Apr 14, 2023 5:17 pm
by Fermin
Hi, can someone please help me?, I'm having a problem with revRotatePoly.
Every time I use it to preview a recently modified graphic object, a polygon I created earlier on that same object shows up. Can anyone help me figure out why this is happening? Thanks a lot.
Re: revRotatePoly
Posted: Fri Apr 14, 2023 5:36 pm
by richmond62
I am not quite sure what you mean.
This seems to work alright:
-
-
Apart from the distinctly non-intuitive:
Code: Select all
revRotatePoly the name of grc "P5", 20
which would be far, far better were it [pseudo]
everything seems to work with no obvious problems.
But, then, I don't understand what you mean by this:
a polygon I created earlier on that same object shows up
Re: revRotatePoly
Posted: Fri Apr 14, 2023 6:00 pm
by Fermin
Thanks Richmond. In my case, adapting to your example, it would be something like this:
Let's say I modify the points of that graphic 'p5' so that instead of a pentagon it draws a square, for example. Okay, I would see the square then. However, as soon as I execute the same code again:
revRotatePoly the name of grc 'p5', 20
The square disappears and the pentagon reappears !!!
It's true that I'm not working with regular polygons, but rather transforming geographic coordinates from Google Earth, but I'm not sure why this is happening. It's very likely that it's some silly mistake on my part, but I've been at it for a while and can't figure out the problem
Re: revRotatePoly
Posted: Fri Apr 14, 2023 6:29 pm
by richmond62
-
INDEED . . .
just the same "over here".

Re: revRotatePoly
Posted: Fri Apr 14, 2023 6:50 pm
by Fermin
"Power to the squares!!!

... Anyway, nothing to do about it. Let's see if I can figure out the solution.

Re: revRotatePoly
Posted: Fri Apr 14, 2023 6:59 pm
by bn
Hi Fermin,
What happens is that revRotatePoly creates a custom property of the polygon the first time it is invoked.
The reason is that the points of the polygon are integers and when rotating integers they "degrade" very quickly. To alleviate that the points of the polygon are saved to the custom property of the graphic "realPoints" as real numbers, i.e. like 123.54321.
If you now repeat revRotatePoly after having changed the points of the graphic Livecode looks first at the custom property and uses the real number to rotate the graphic again.
You can avoid that by doing after changing the points of your graphic
Code: Select all
set the realPoints of graphic "myGraphic" to empty
and then do a revRotatePoly. The polygon will then use the new points for rotation.
Kind regards
Bernd
Re: revRotatePoly
Posted: Fri Apr 14, 2023 7:17 pm
by richmond62
I would just suppose this is where one has to get one's head
round
effective points and
real points . . . a bit like fake news.

Re: revRotatePoly
Posted: Fri Apr 14, 2023 7:37 pm
by Fermin
Thank you, Richmond... and Thank you very much, Bernd!!! Understood, applied, and problem solved.

Re: revRotatePoly
Posted: Fri Apr 14, 2023 8:12 pm
by richmond62
Thank you very much, Bernd!!!
He always has 'a march' on the rest of us.

Re: revRotatePoly
Posted: Fri Apr 14, 2023 8:27 pm
by bn
richmond62 wrote: ↑Fri Apr 14, 2023 8:12 pm
Thank you very much, Bernd!!!
He always has 'a march' on the rest of us.
As far as march is concerned:
My favorite radio ad from Pan Am was
Son, don't walk if you don't have to.
Kind regards
Bernd