Message Boards Message Boards

0
|
675 Views
|
6 Replies
|
2 Total Likes
View groups...
Share
Share this post:

FilledCurve and lopsided mandalas

Posted 1 month ago

The following code makes the mandala in the image below. Notice that one petal of the mandala is shorter than all the others. I'm trying to get them all to be the same. It seems that this unwanted behavior is due to the FilledCurve's feature of closing all curves, even if they already close themselves. Does anyone see a way to prevent this from happening to produce a symmetric mandala? (Yes, I'm aware of the very cool resource function "RandomMandala", but I'm trying to roll my own for a special purpose.)

curve = BSplineCurve[{{0, 0}, {1, 1}, {3, -7}, {3, 1}, {0, 0}}];
rot = Table[RotationTransform[i*\[Pi]/15][curve], {i, 30}];
gr = Graphics[{EdgeForm[Black], FaceForm[Yellow], 
   FilledCurve[rot]}]

enter image description here

Thanks in advance.

POSTED BY: Mark Greenberg
6 Replies
Posted 1 month ago

So, while the FilledCurve is automatically closing the curve, the individual BSplineCurves themselves aren't actually closed. Yes, you've duplicated the origin point, but the behavior is still different if you set the SplineClosed option to True or False. And so, the FilledCurve is doing its thing, creating "closures" between adjacent curves, but the final "closure" doesn't work as a spline closure. Or at least that's my intuition of what's going on. What I would do is to manipulate the points themselves and make one big spline curve.

rotationCount = 30;
splinepts = {{0, 0}, {1, 1}, {3, -7}, {3, 1}, {0, 0}};
mandalapts = 
  Catenate[
   Table[RotationTransform[i*2  \[Pi]/rotationCount][splinepts], {i, 
     rotationCount}]];
mandalacurve = BSplineCurve[mandalapts, SplineClosed -> True];
Graphics[{EdgeForm[Black], FaceForm[Yellow], 
  FilledCurve[mandalacurve]}]

enter image description here

It's important that SplineClosed be True (default is False) so that the first and last points ({0,0}) get "doubled up" like all the others.

POSTED BY: Eric Rimbey
Posted 1 month ago

Ah, I see. Thank you, Eric. The way I was doing it, FilledCurve's argument was a list of B-spline curves. Your solution is a single closed B-spline curve. I'm not sure I would have come up with that on my own. That's the solution I need. : )

POSTED BY: Mark Greenberg

I didn't have the time to work this out, but maybe try omitting the {0,0} from the second (to the last) BSpline? This shows what I mean for the first and second spline:

Graphics[{EdgeForm[Black], FaceForm[Yellow], 
  FilledCurve[{BSplineCurve[{{0, 0}, {Cos[\[Pi]/7] - Sin[\[Pi]/7], 
       Cos[\[Pi]/7] + Sin[\[Pi]/7]}, {3 Cos[\[Pi]/7] + 
        7 Sin[\[Pi]/7], -7 Cos[\[Pi]/7] + 
        3 Sin[\[Pi]/7]}, {3 Cos[\[Pi]/7] - Sin[\[Pi]/7], 
       Cos[\[Pi]/7] + 3 Sin[\[Pi]/7]}, {0, 0}}], 
    BSplineCurve[{{-Cos[(3 \[Pi])/14] + Sin[(3 \[Pi])/14], 
       Cos[(3 \[Pi])/14] + Sin[(3 \[Pi])/14]}, {7 Cos[(3 \[Pi])/14] + 
        3 Sin[(3 \[Pi])/14], 
       3 Cos[(3 \[Pi])/14] - 
        7 Sin[(3 \[Pi])/14]}, {-Cos[(3 \[Pi])/14] + 
        3 Sin[(3 \[Pi])/14], 
       3 Cos[(3 \[Pi])/14] + Sin[(3 \[Pi])/14]}, {0, 0}}]}]}, 
 ImageSize -> Full]
POSTED BY: Arnoud Buzing
Posted 1 month ago

Thanks for the response, Arnoud. I did experiment with deleting and adding {0, 0} in strategic locations because I suspected that the problem stemmed from closing of the last segment with the first segment. I don't think I tried removing it from the beginning of the last segment like you did. This looks promising, though I'll take a look at Eric's solution before working out the code for yours.

POSTED BY: Mark Greenberg
Posted 1 month ago

Interesting approach, Gianluca. Thanks. I had not thought of superimposing two curves for the color & outline. I was hoping to preserve the odd-even filling scheme if possible. Your solution results in a fill of the entire shape.

POSTED BY: Mark Greenberg

Here is a variation:

curve = BSplineCurve[{{0, 0}, {1, 1}, {3, -7}, {3, 1}, {0, 0}}];
Graphics[{{Yellow,
   Table[Rotate[FilledCurve@curve, i  \[Pi]/15, {0, 0}], {i, 30}]}, 
  Table[Rotate[curve, i  \[Pi]/15, {0, 0}], {i, 30}]}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract