Hi, I am currently struggeling with the task to place rectangular tiles "nicely" in a circle with radius = 100 ....

Starting point is a hash %hash{$x}{$y}=$color which associates a color to a coordinate.

My current approach is to calculate the distinct number of x and y and determine the tile size for a square 100x100. Then I walk through the coordinates and determine the outermost point with respect to the center of the square. I then calculate the shrinkage factor so that this outermost point fits in the circle. After that, I can resize each tile using this factor and the tiles fit in the circle.

This approach works nicely with regular tile arrays, see for instance this picture: http://www.myimg.de/?img=tile136472.png

If the tile array is irregular, however, the algorithm fails. The problem is that the algorithm always implies that the tile array is a square. This leads to different distances of the tile points to the circle in the following picture: http://www.myimg.de/?img=tile2a1863.png

The algorithm calculates assuming the presence of the blue tiles: http://www.myimg.de/?img=tile316d1d.png"

With these few tiles, one might argue that this still looks ok. If there are really many tiles, no inter-tile distance and the arrangement is asymmetric, it looks strange, see this picture: http://www.myimg.de/?img=tile417dd5.png

I can't really think of an algorithm that somehow puts the tiles in the "middle" of the circle, meaning that in average all outer points of a tile have the same distance to the circle. I want to achieve, that the tiles "look" centered.

I thought of walking through the coordinates row-wise and calculate the outermost points for each row. with some geometry it is easy the get the distance to the circle. i then have an array of distances of the outermost point/tile for each row. the tricky part (where i am stuck) is, how to move/resize the tiles now ... ;(

maybe you guys have an idea

Best regards Jan

In reply to Placeing Tiles in a Circle by janDD

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.