Re: Points of Regular Polygon

2016-11-29 Thread Randy Hengst
Well, this was fun. I write a question, go teach class, and come back to a very 
interesting conversation.

Thanks all.

be well,
randy
www.classroomFocusedSoftware.com



> On Nov 29, 2016, at 1:24 PM, hh  wrote:
> 
> I should have better used the wording
>"graphic of type" than "graphic of style"
> because we can
> set the style of grc 1 to "polygon"
> for example (the function again, just for the completeness here):
> 
> on mouseUp
>   if there is no grc "poly" then create grc "poly"
>   set style of grc "poly" to "polygon"
>   -- 7 vertices, 1 vertix at 12 o'clock, radius 42, loc (100,100)
>   set points of grc "poly" to regularPoints(7,42,100,100)
>   set foreColor of grc "poly" to "0,128,128" -- teal
>   set lineSize of grc "poly" to 2 
> end mouseUp
> 
> -- N is the number of vertices
> -- x0,y0 is the center of the polygon
> -- r is the radius of the polygon
> -- b is the angle of rotation in degrees
> -- (positive b turns clockwise, negative b turns ccw)
> function regularPoints n,r,x0,y0,b
>   put 2*pi/n into cn
>   -- n vertices --> n+1 points if 'closed' polygon
>   -- usually done by setting last=first
>   -- This is here true as sin(0)=sin(2*pi) and cos(0)=cos(2*pi)
>   put empty into pts
>   if b=0 or b is empty then
>  ## compute unrotated n+1 vertices of the n-sided regular polygon
>  repeat with j=0 to n
> put CR & (round(r*sin(j*cn)+x0),round(-r*cos(j*cn)+y0)) after pts
>  end repeat
>   else
>  ## compute *rotated* n+1 vertices of the n-sided regular polygon
>  put sin(pi*b/180) into s; put cos(pi*b/180) into c 
>  repeat with j=0 to n
> put round( r*sin(j*cn)) into sx; put round(-r*cos(j*cn)) into sy
> put CR & ( (round(x0+c*sx-s*sy),round(y0+c*sy+s*sx)) ) after pts
>  end repeat
>end if
>return char 2 to -1 of pts
> end regularPoints
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Points of Regular Polygon

2016-11-29 Thread hh
I should have better used the wording
"graphic of type" than "graphic of style"
because we can
 set the style of grc 1 to "polygon"
for example (the function again, just for the completeness here):

on mouseUp
   if there is no grc "poly" then create grc "poly"
   set style of grc "poly" to "polygon"
   -- 7 vertices, 1 vertix at 12 o'clock, radius 42, loc (100,100)
   set points of grc "poly" to regularPoints(7,42,100,100)
   set foreColor of grc "poly" to "0,128,128" -- teal
   set lineSize of grc "poly" to 2 
end mouseUp

-- N is the number of vertices
-- x0,y0 is the center of the polygon
-- r is the radius of the polygon
-- b is the angle of rotation in degrees
-- (positive b turns clockwise, negative b turns ccw)
function regularPoints n,r,x0,y0,b
   put 2*pi/n into cn
   -- n vertices --> n+1 points if 'closed' polygon
   -- usually done by setting last=first
   -- This is here true as sin(0)=sin(2*pi) and cos(0)=cos(2*pi)
   put empty into pts
   if b=0 or b is empty then
  ## compute unrotated n+1 vertices of the n-sided regular polygon
  repeat with j=0 to n
 put CR & (round(r*sin(j*cn)+x0),round(-r*cos(j*cn)+y0)) after pts
  end repeat
   else
  ## compute *rotated* n+1 vertices of the n-sided regular polygon
  put sin(pi*b/180) into s; put cos(pi*b/180) into c 
  repeat with j=0 to n
 put round( r*sin(j*cn)) into sx; put round(-r*cos(j*cn)) into sy
 put CR & ( (round(x0+c*sx-s*sy),round(y0+c*sy+s*sx)) ) after pts
  end repeat
end if
return char 2 to -1 of pts
end regularPoints


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Points of Regular Polygon

2016-11-29 Thread Richmond Mathewson



On 11/29/16 9:09 pm, Richard Gaskin wrote:

Richmond Mathewson wrote:

> Oddly enough, that may have uncovered a bug in LC 9 dp3 . . .
>
> I thought I would set the points of a polygon graphic to the points
> of the regular polygon graphic that I had exported into a scrolling
> list field.
>
> But when I selected 'Polygon Graphic' from the Menu/Object/New
> Control/Polygon Graphic
> (Mac OS 10.7.5: yeah, yeah, I know, 'tisn't supported for LC 9: go
> and try it on a newer Mac running Mac OS Rocky Mountain) and no
> polygon graphic appeared on my stack.
>
> To contextualise this: there is no problem if I select 'regualr
> polygon graphic'.

An irregular polygon has no inherent shape; its points must be drawn 
by the user.


When I choose that menu item (in v9.0 dp3 on Ubuntu) the tool changes 
to graphic polygon, and allows me to draw it out as expected.



Not over "here" I'm afraid.

Richmond.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Points of Regular Polygon

2016-11-29 Thread Richard Gaskin

Richmond Mathewson wrote:

> Oddly enough, that may have uncovered a bug in LC 9 dp3 . . .
>
> I thought I would set the points of a polygon graphic to the points
> of the regular polygon graphic that I had exported into a scrolling
> list field.
>
> But when I selected 'Polygon Graphic' from the Menu/Object/New
> Control/Polygon Graphic
> (Mac OS 10.7.5: yeah, yeah, I know, 'tisn't supported for LC 9: go
> and try it on a newer Mac running Mac OS Rocky Mountain) and no
> polygon graphic appeared on my stack.
>
> To contextualise this: there is no problem if I select 'regualr
> polygon graphic'.

An irregular polygon has no inherent shape; its points must be drawn by 
the user.


When I choose that menu item (in v9.0 dp3 on Ubuntu) the tool changes to 
graphic polygon, and allows me to draw it out as expected.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Points of Regular Polygon

2016-11-29 Thread hh
Richmond M.
> Setting points does no good at all.

That's not true if graphics are involved. Just follow the rules.

You cannot _set_ the points of a graphic of type "regular".
You can _get_ the points since LC 7 (thanks to Mark Wieder).

Just the same with a graphic of type "Oval" or "Rectangle" or "Line".
(A grc "Line" is handled as "Polygon" if you set more points than 2).

But you can set the points of a graphic of type "Polygon". This is
the only type of graphic that has settable points (or relativePoints).

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Points of Regular Polygon

2016-11-29 Thread Richmond Mathewson
Aha: the IDE just plonks a pointless polygon graphic in your card, so it 
is invisible.


Setting points does no good at all.

Richmond.

On 11/29/16 8:35 pm, Richard Gaskin wrote:

Richmond Mathewson wrote:

> ...BUT one cannot deform a regular polygon...

...because it would then no longer be a regular polygon.

To make an irregular polygon use the polygon style.  If you need it to 
have regular points you can first create a regular polygon, get its 
effective points, change its style to "polygon", then set the points 
and adjust them however you like:


   put the effective points of grc 1 into tPts
   set the style of grc 1 to "polygon"
   set the points of grc 1 to tPts




___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Points of Regular Polygon

2016-11-29 Thread Richmond Mathewson

Oddly enough, that may have uncovered a bug in LC 9 dp3 . . .

I thought I would set the points of a polygon graphic to the points of the
regular polygon graphic that I had exported into a scrolling list field.

But when I selected 'Polygon Graphic' from the Menu/Object/New 
Control/Polygon Graphic
(Mac OS 10.7.5: yeah, yeah, I know, 'tisn't supported for LC 9: go and 
try it on a newer Mac running

Mac OS Rocky Mountain) and no polygon graphic appeared on my stack.

To contextualise this: there is no problem if I select 'regualr polygon 
graphic'.


Richmond.

On 11/29/16 8:35 pm, Richard Gaskin wrote:

Richmond Mathewson wrote:

> ...BUT one cannot deform a regular polygon...

...because it would then no longer be a regular polygon.

To make an irregular polygon use the polygon style.  If you need it to 
have regular points you can first create a regular polygon, get its 
effective points, change its style to "polygon", then set the points 
and adjust them however you like:


   put the effective points of grc 1 into tPts
   set the style of grc 1 to "polygon"
   set the points of grc 1 to tPts




___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Points of Regular Polygon

2016-11-29 Thread hh
Why not simply computing the points by yourself?

Excerpt from the the main script of
Raspi stack #2: RegularPolygons3
(http://forums.livecode.com/viewtopic.php?p=98716#p98716)

-- N is the number of vertices
-- x0,y0 is the center of the polygon
-- r is the radius of the polygon
-- b is the angle of rotation in degrees
-- (positive b turns clockwise, negative b turns ccw)
function regularPoints n,r,x0,y0,b
   put 2*pi/n into cn
   -- n vertices --> n+1 points if 'closed' polygon
   -- usually done by setting last=first
   -- This is here true as sin(0)=sin(2*pi) and cos(0)=cos(2*pi)
   put empty into pts
   if b=0 or b is empty then
  ## compute unrotated n+1 vertices of the n-sided regular polygon
  repeat with j=0 to n
 put CR & (round(r*sin(j*cn)+x0),round(-r*cos(j*cn)+y0)) after pts
  end repeat
   else
  ## compute *rotated* n+1 vertices of the n-sided regular polygon
  put sin(pi*b/180) into s; put cos(pi*b/180) into c 
  repeat with j=0 to n
 put round( r*sin(j*cn)) into sx; put round(-r*cos(j*cn)) into sy
 put CR & ( (round(x0+c*sx-s*sy),round(y0+c*sy+s*sx)) ) after pts
  end repeat
end if
return char 2 to -1 of pts
end regularPoints


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Points of Regular Polygon

2016-11-29 Thread Richmond Mathewson

Indeed.

Richmond.

On 11/29/16 8:35 pm, Richard Gaskin wrote:

Richmond Mathewson wrote:

> ...BUT one cannot deform a regular polygon...

...because it would then no longer be a regular polygon.

To make an irregular polygon use the polygon style.  If you need it to 
have regular points you can first create a regular polygon, get its 
effective points, change its style to "polygon", then set the points 
and adjust them however you like:


   put the effective points of grc 1 into tPts
   set the style of grc 1 to "polygon"
   set the points of grc 1 to tPts




___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Points of Regular Polygon

2016-11-29 Thread Richard Gaskin

Richmond Mathewson wrote:

> ...BUT one cannot deform a regular polygon...

...because it would then no longer be a regular polygon.

To make an irregular polygon use the polygon style.  If you need it to 
have regular points you can first create a regular polygon, get its 
effective points, change its style to "polygon", then set the points and 
adjust them however you like:


   put the effective points of grc 1 into tPts
   set the style of grc 1 to "polygon"
   set the points of grc 1 to tPts

--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Points of Regular Polygon

2016-11-29 Thread Richmond Mathewson

That's true; BUT one cannot deform a regular polygon by doing a

set the points of grc "XYZ" to fld "ABC"

. . . 'Tis regular, don't cha know?

Richmond.

On 11/29/16 7:57 pm, Devin Asay wrote:

On Nov 29, 2016, at 10:52 AM, Randy Hengst  wrote:

Hi All,

As I’ve looked through the list archives, I know the answer to my quetion was 
‘no' back in 2013… just checking to see if I’ve missed something.

Is there a way to get the points (vertices) of a a regular polygon?

I want to set the the number of sides of the regular polygon (which is easily 
scripted), and then I’d like to find the loc of each of the vertices…

Is the answer to finding the points of the vertices still no?

It’s yes!

   put the effective points of graphic “foo”

Devin


Devin Asay
Director
Office of Digital Humanities
Brigham Young University

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Points of Regular Polygon

2016-11-29 Thread Scott Rossi
Sounds like you want the effective points property (of grc “abc”)?

Regards,

Scott Rossi 
Creative Director 
Tactile Media, UX/UI Design 

> On Nov 29, 2016, at 9:52 AM, Randy Hengst  wrote:
> 
> Hi All,
> 
> As I’ve looked through the list archives, I know the answer to my quetion was 
> ‘no' back in 2013… just checking to see if I’ve missed something.
> 
> Is there a way to get the points (vertices) of a a regular polygon?
> 
> I want to set the the number of sides of the regular polygon (which is easily 
> scripted), and then I’d like to find the loc of each of the vertices… 
> 
> Is the answer to finding the points of the vertices still no?
> 
> be well,
> randy
> www.classroomFocusedSoftware.com
> 
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Points of Regular Polygon

2016-11-29 Thread Devin Asay

> On Nov 29, 2016, at 10:52 AM, Randy Hengst  wrote:
> 
> Hi All,
> 
> As I’ve looked through the list archives, I know the answer to my quetion was 
> ‘no' back in 2013… just checking to see if I’ve missed something.
> 
> Is there a way to get the points (vertices) of a a regular polygon?
> 
> I want to set the the number of sides of the regular polygon (which is easily 
> scripted), and then I’d like to find the loc of each of the vertices… 
> 
> Is the answer to finding the points of the vertices still no?

It’s yes!

  put the effective points of graphic “foo”

Devin


Devin Asay
Director
Office of Digital Humanities
Brigham Young University

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode