Points in a regular polygon

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Points in a regular polygon

Post by dunbarx » Wed Nov 27, 2013 7:07 pm

Though it may make no sense to ascribe points to an oval, it ought to be possible to ascribe them to a regular polygon. Currently only irregular polygons, freehand curves and lines have a valid list of points. But a polygon certainly has well defined points, after all, the engine draws them with actual points anchoring the shape of the graphic. The issue came up with a request to have an object move along the perimeter of a circle. A regular polygon with hundreds of sides would look just like a circle, and of course moving along the points of that polygon would be simple.

Even a rectangle graphic has no points, or rather, like the others, that property returns empty. But it sure has a rect.

Craig Newman
Last edited by dunbarx on Wed Jun 25, 2014 3:32 pm, edited 1 time in total.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Points in a regular polygon

Post by [-hh] » Sat Nov 30, 2013 1:41 am

..........
Last edited by [-hh] on Wed Aug 13, 2014 2:10 pm, edited 1 time in total.
shiftLock happens

ThatOneGuy
Posts: 77
Joined: Fri Jan 04, 2013 9:57 am

Re: Points in a regular polygon

Post by ThatOneGuy » Wed Dec 11, 2013 8:38 am

The idea behind the regular polygons is that they don't require specifying points. Changing the points of a regular poly would cause it to no longer be regular. An oval, just like a regular poly, is not defined by points, but by its rectangle. The difference is that the oval is also defined by its arc and angle, while the regular poly is defined by its sides and angle.

If you want to use points, then use the freehand poly tool to create an irregular poly object and set the "points" or it to what you want. This is done easily enough using a repeat loop and you can have hundreds of points continually updating on multiple polygons without seeing any lag or errors. I've tested this.

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Points in a regular polygon

Post by [-hh] » Wed Dec 11, 2013 10:05 am

..........
Last edited by [-hh] on Wed Aug 13, 2014 2:10 pm, edited 1 time in total.
shiftLock happens

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Points in a regular polygon

Post by dunbarx » Thu Dec 12, 2013 12:56 am

ThatOneGuy.

What Hermann said.

This is exactly how this started. In order to create a freehand graphic locked to the "points" of, say, a 50 sided regular polygon, you cannot:

set the points of grc "free" to the points of grc "regular"

You have to draw the thing by hand. Then, and only then, do you have a regular, many sided polygon with real, addressable points. This came about as one simple way to have an image track the perimeter of a circle. I wanted to create a hundred-sided regular polygon (which sure looks like a circle) and run the thing along its points. What do you know, it don't got any.

Craig

ThatOneGuy
Posts: 77
Joined: Fri Jan 04, 2013 9:57 am

Re: Points in a regular polygon

Post by ThatOneGuy » Thu Dec 12, 2013 5:49 am

I see what you mean here.

You don't have an interest in seeing the points of regular graphics for the purpose of editing them, you just want a way of accessing them so that you can use them.

That may indeed be a worthwhile feature.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Points in a regular polygon

Post by mwieder » Fri Jan 17, 2014 7:54 pm

OK - this may be one I can take on, because it will probably tie in with the work I did in allowing non-integer point values. I'll have a look at the code over the weekend and see what it looks like.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Points in a regular polygon

Post by mwieder » Fri Jan 24, 2014 8:42 pm

Adding this feature turned out to be pretty easy.
Before submitting the pull request, though...

This will allow getting the points of regular polygons, but not setting them.
The fix does allow you to set the points of a polygon to the points of a regular polygon.

I realize that this is what was requested, but with other graphic objects you can both get and set the points, so I can see the objection being raised that this is an exception. It would have to be documented as such explicitly. It wouldn't really make sense to try to set the points of a regular polygon.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: Points in a regular polygon

Post by BvG » Sat Jan 25, 2014 3:30 pm

That's so cool to have! Now do it for rectangles, rounded rectangles, and especially ovals :P

On a slightly more serious feature creep question, It could theoretically be useful to set a single point of a regular polygon, then have LC calculate all the other points according to the settings of "the sides" and "the rotation"... but yeah, reading them is a big advantage already.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Points in a regular polygon

Post by mwieder » Sat Jan 25, 2014 6:04 pm

Rectangles and rounded rectangles are included.
Have to check ovals... I don't remember off the top of my head.

... and yeah, I looked into setting the points of a regular polygon, but

a) the math gets pretty involved, and
b) what do you do if the points don't make a regular polygon? Regular polygons are subject to many more restrictions than freeform polygons - in addition to the points having to be in exactly the right place, they have to be symmetrical and well, regular. If the number of side changes because the number of points changes, you have to set that property as well. Etc. Probably better just to say "make me a regular polygon with this rect and this many sides" and be done with it.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Points in a regular polygon

Post by Mark » Sat Jan 25, 2014 11:07 pm

Mark,

Could this be something like the "effective points"? In most, if not in all cases, an "effective" property can be gotten but not set and thus it wouldn't be an exception. The effective points and the points of an irregular polygon would probably be equal.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Points in a regular polygon

Post by mwieder » Sun Jan 26, 2014 2:54 am

@Mark: That's brilliant. Let me look into what that would take. I glanced at the "effective" settings this morning, but just briefly.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Points in a regular polygon

Post by mwieder » Mon Jan 27, 2014 1:14 am

OK...

"the points of" a rectangle, rounded rectangle, regular polygon now return nothing.
"the effective points of" any of those return a list of points.

I don't think "the points of an oval" makes much sense. It's easy to get the rect of an oval, the center, etc. But the points of an oval would depend on the resolution you wanted. I can easily return the points of an oval as the corner points of its rectangle, but that doesn't gain you anything that the rect of the oval gives you.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Points in a regular polygon

Post by dunbarx » Mon Jan 27, 2014 2:02 am

Mark.

Have you added this to the engine? If so, where can I see it?

And I agree, as I first said, the points of an oval is pushing it...

Craig

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Points in a regular polygon

Post by mwieder » Mon Jan 27, 2014 3:10 am

I pushed the code to github and submitted a pull request.
That's my part of this.
Now it's up to the team to get around to evaluating it and either pulling it into the code base or <whatever else they decide to do>.

Post Reply