Hi Linda, You may find this link of interest as well:
http://tauday.com/ Regards, Simon -----Original Message----- From: programming-boun...@jsoftware.com [mailto:programming-boun...@jsoftware.com] On Behalf Of Linda Alvord Sent: 22 March 2012 17:45 To: 'Programming forum' Subject: [Jprogramming] FW: Shamrock solution. I posted the shamrock challenge on 3/2/2012 and received this response from David Ward Lambert on 3/12/2012. It has caused me to delve into polar graphs which is a little premature for these challenges. But it has been great fun and I've changed how I think about lots of things. I recommend this strange post as well as Tau Day posts on Google: http://laughingsquid.com/pi-is-wrong/ What he did was to find the "inside" of a trifolium, or three petal rose in polar coordinates. It is essentially how you would "paint" the trifolium. He said I could share this with everyone, and I didn't want to post it until there were some options which "painted" the inside of a circle. So I hope you will enjoy his masterful approach to a celebration of St. Patrick's Day. Linda -----Original Message----- From: David Ward Lambert [mailto:b49p23t...@stny.rr.com] Sent: Friday, March 02, 2012 2:43 PM To: lindaalv...@verizon.net Subject: Shamrock solution. NB. Save message or attachment as a script. NB. Run on 80 width and height terminal with, roughly, NB. ----------------------------------- NB. shell_prompt$ jconsole shamrock_dwl.ijs NB. ----------------------------------- NB. Not bad in jgtk except that the final plot doesn't work. NB. Works in jhs---remove the final line, exit 0l TAU=: 2p1 NB. http://laughingsquid.com/pi-is-wrong/ range=: 1&$: : (* (%~ i.)) radian_range=: TAU&range grid_cartesian=: 2&$: : ({@:(# <@:(%~ i:))) NB. returns delightful boxes NB. create_round_mask radius returns Boolean square array, 1 within circle NB. create_round_mask result depends on comparison tolerance, 9!:18, 9!:19 create_round_mask=: (1-1e_14) >: |@:j./@>@:grid_cartesian NB. 1j1&#&.|: is slow and fat expand_for_character_cell_display=: 1j1&#"1 Gft_dwl=: 1 : 0 5 m Gft_dwl y : TOP_VIEW_TREE=.((create_round_mask x)})(m&,:)y{~(2#>:+:x)?@:$(#y) expand_for_character_cell_display TOP_VIEW_TREE ) smoutput ,.'Big GFT';BIG_GFT=: 8' 'Gft_dwl'/|\O' smoutput ,.'Moonlit lemon tree';LEMON_TREE_AT_NIGHT=: 5'.'Gft_dwl'/|\o' smoutput ,.'Underbearing carambola';PARCHED_STAR_FRUIT=: 5' 'Gft_dwl'*',3#'/|\' trifolium=: 0&$: : (4 : 0) NB. trifolium radians ROTATION=: 3 * x PHI=. y R=. ROTATION (1 o. ] p.~ 3 ,~ [) PHI R *"1 (2 1 o./PHI) ) create_shamrock_mask=: 0&$: : (4 : 0)"0 NB. rotation create_shamrock_mask half_size GRID=. i:1 j. y RADIAL_DENSITY=. 8 NB. An adjective would help to free these parameters OUTLINE_DENSITY=. 555 T=. x trifolium radian_range OUTLINE_DENSITY FR=. range RADIAL_DENSITY NB. radial factors FR=. %:@:(+ 0&=) FR NB. square root makes the bigger factors closer. The hook merely substitutes a 1 for the 0 INDEXES=. ~. <"1 ,/ |: GRID I. T*/FR 1 INDEXES } 0 $~ 2 # >: y ) NB. in following sentence 37 is roughly the half width of the final shamrock and 0.2 controls leaf size smoutput ,.'St. Pat';expand_for_character_cell_display ' X'{~+./ (1 _1*0.2) create_shamrock_mask 37 smoutput'If you replace the 3s in trifolium with 4, does the code draw a lucky clover?' smoutput'See comments about global comparison tolerance.' load'plot' plot ;/ trifolium radian_range 100 exit 0 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm