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

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Points in a regular polygon

Post by capellan » Mon Jan 27, 2014 6:19 am

Notice that a regular polygon of 100 sides
looks very similar to a circle or oval. :D

So the effective points of such polygon
would be really useful, too.

Al

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 » Tue Jan 28, 2014 8:02 pm

mwieder wrote: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.
Obviously i'd be interested in the actual points that draw the oval. So basically a full fledged freehand polygon, using whatever resolution LC uses itself.

Wait... are you saying that you don't actually give the necessary points to create a rounded polygon? So only the corner points of the polygon, as if it'd be a rectangle? if yes, i'd rater not to have anything, because that's what the various positioning properties of objects already sufficiently deliver, and there's no need to replicate it in a confusing manner. Of course the points of a rectangle are the topleft & the bottomRight, so that makes sense, but only for that type of graphic.
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 » Sun Jun 22, 2014 5:19 am

My pull request was accepted, and now you soon can have the effective points of rectangles, rounded rectangles, regular polygons, and ovals. This will allow you to, for example, set the points of a polygon or curve to the effective points of a rounded rectangle. Or to iteratively move an image along the points of an oval. Or whatever.

[-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] » Sun Jun 22, 2014 1:45 pm

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

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 Jun 23, 2014 8:06 pm

In the IDE object inspector get the points filled with the points of current graphic whenever one switches the type of the graphic
from "roundRect" or "rectangle" or "oval" or "regular"
to "polygon" or "curve" or "line" (e.g. line 1 of current points for last)?
The property inspector is part of the ide, not the engine. It has a mind of its own as to what to display, and it's ripe for updating or replacing. There are third-party replacements that work much better.
Are the relativePoints also 'directly' available?
yes.
How will revRotatePoly work in connection to this new function?
I've only updated the engine code. The revRotatePoly command is also part of the ide (the code is in the revCommon button). I think the code should be rewritten, as it has the tendency to mangle polygons when it rotates them: case in point, try rotating a polygon or curve through 90 degrees four times and see if you end up with your original image. Someone with better math than mine should probably take a look at the code and submit a FIX: bug report.

[-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] » Mon Jun 23, 2014 11:35 pm

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

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 Jun 23, 2014 11:51 pm

! Many thanks for a quick reply. Actually truncating or rounding of the calculated points is no longer necessary - points of a graphic no longer need to be integers. I did a test that removes this restriction and it properly rotates graphics and returns to the original shape and size. But I'll also look over your stack later tonight when I get the chance. I'd also love to move this code into the engine for speed. Someday. Always a work in progress.

[-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] » Tue Jun 24, 2014 12:22 am

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Points in a regular polygon

Post by FourthWorld » Tue Jun 24, 2014 1:04 am

[-hh] wrote:
mwieder wrote:Points of a graphic no longer need to be integers.
In the last months I often saw here this optimistic view. Where does it come from?
I think it comes from Skia. This works in v6.6.2:

Code: Select all

set the rect of grc 1 to 100.1,200.2,164.43,400.56
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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 » Tue Jun 24, 2014 3:15 am

Actually, non-integer points for graphics is a change I submitted to the engine code last year.

[-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] » Tue Jun 24, 2014 11:14 am

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

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 » Tue Jun 24, 2014 5:39 pm

Ah. I see what you mean now.
What I implemented last year was a change so that setting non-integer points would no longer crash the engine.
I'll have a look at how the engine actually applies points, but I think actually using non-integer values may take a more sweeping structural change, something like what you suggested with zeropoints, i.e., storing the actual as well as the applied values.

[-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] » Tue Jun 24, 2014 8:26 pm

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

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 » Wed Jun 25, 2014 8:46 pm

I submitted a "FIX:" request based on what we've been doing here. The rounding functions are not necessary, as the engine does its own rounding for the display, and saving the actual floating-point values to work with internally solves the problem of distorting the graphics. After the next build of LC 6.7 this will work with the other graphics styles as well.

http://quality.runrev.com/show_bug.cgi?id=12692

Post Reply