Message Boards Message Boards

Cut some digital snowflakes these holidays!

Posted 11 years ago
Do you remember when a friend showed you how to cut a snowflake from a paper? Perhaps your family does it to decorate and celebrate holidays with this simple but artistic activity. I thought, why not to make something like this in form of an app? We then can use this custom-tailored art for an e-card, holiday blog post or whatever your imagination tells you.

We already have quite a few snowflake related Demonstrations, for example Parametric Snowflake Design. But I wanted something to imitate the actual process of cutting a snowflake from a sheet of paper – see images below. First thing to remember is that we first fold paper up to the 12th part – a slice of 30 degrees span. Then we cut it artistically and unfold to see the effect of cutting.



As we will deal with very different medium, it will bring some new features to the process. For instance:

 1) One cannot undo cutting out a piece of paper, while interactively we can
 2) We can see effect of molding 12th part reflected on the whole design immediately 
 3) Overlapping slices wider then 30 degrees would be hard with paper
 4) We can infinitely and arbitrary sophisticate the process due to flexibility of programing language

So without further ado below is an animation of how the snowflake designer works and below is the code, which is pretty short.



 Manipulate[
 
  Graphics[{
    
    {PointSize[size], Red, Point[pt]},
    
    GeometricTransformation[
     {#, GeometricTransformation[#, ReflectionTransform[{1, 0}]]} &@
      {EdgeForm[Directive[White, Opacity[.8]]],
      FaceForm[Directive[White, Opacity[.4]]],
      type[Join[{{0, 0}}, pt]]},
    Table[RotationTransform[a], {a, 0, 2 Pi - Pi/3, Pi/3}]],
   
   }, Background -> Black, ImageSize -> 400 {1, 1}],

{{type, Polygon}, {Polygon -> "sharp", spline -> "round"}},
{{size, .01}, 0, .1},
{{pt, {{0, 1}, {1/4, 1}, {1/2, 1}}}, Locator, Appearance -> None, LocatorAutoCreate -> True},

FrameMargins -> 0, Initialization -> (
spline[pt_] := FilledCurve[BSplineCurve[pt, SplineClosed -> True]])]

To add or remove locator command+click on Mac and control+click on Windows.

The app is based on controlling the shape of a 12th part with help of locators. The resulting shape is immediately reflected to form a 6th part, which is then further rotated 5 times to complete the whole snowflake. Reflections and rotations are made with help of GeometricTransformation function. One can choose sharp polygons or smooth spline curves. Of course the real snowflakes do not grow like this, but it does resemble the way we toy with scissors and paper. Why do we need 12th part and not 6th, if snowflakes have hexagonal symmetry? Well this is because snowflakes has to be symmetric with respect to reflection between the left and right halves of each 6th part.

Instead of using GeometricTransformation to transform the shapes, we could use matrixes to transform sets of points and then build the single final shape out of the whole set of points. To demonstrate this I will write a short function and generate few random snowflakes so you can see what diversity of shapes can be achieved with the app above.

Enjoy! If you come up with some nice shapes – get a screenshot and add them in comments to this post! Or let me know how we can improve this code. Also take a look how our sister Mathematica Stackexchange community celebrates with snowflakes.

Happy holidays!
Vitaliy

 snow[pt_] := Graphics[
  
   {EdgeForm[Directive[White, Opacity[.8]]],
    FaceForm[Directive[White, Opacity[.4]]],
    Polygon[
     Outer[#1.#2 &,
      Table[RotationMatrix[a], {a, 0, 2 Pi - Pi/3, Pi/3}],
      Join[Map[ReflectionMatrix[{1, 0}].# &, #], #] &@
       Join[{{0, 0}}, pt],
     1]]}
 
  , Background -> Black, ImageSize -> 100 {1, 1}]

Grid[Partition[ParallelTable[
   snow[RandomReal[{-1, 1}, {RandomInteger[{3, 9}], 2}]],
   {64}], 8], Spacings -> {0, 0}]



And these are from modified code of the demonstration mentioned above - Parametric Snowflake Design.
 x1[a_, b_, c_, t_] :=  Sin[.5 t] - a Sin[b t]*Cos[t] - .1 c Sin[10 b t];
 y1[a_, b_, c_, t_] :=  Cos[.5 t] - a Sin[b t]*Sin[t] - .1 c Cos[10 b t];
 
 
 GraphicsGrid[Partition[ParallelTable[
    With[{
      a = RandomReal[{-1.5, 1.5}],
      b = RandomInteger[{3, 15}],
      c = RandomReal[{0, 1.5}],
     clr1 = Black,
     clr2 = RGBColor @@ RandomReal[1, 3],
     clr3 = RGBColor @@ RandomReal[1, 3],
     thick = RandomReal[{.04, .5}],
     tm = 1},
    ParametricPlot[
     Evaluate[{{x1[a, b, c, t], y1[a, b, c, t]}, {x1[a, b, c, t],
        y1[a, b, c, t]}}], {t, 0, tm 4 \[Pi]},
     PlotStyle -> {{clr2, Thickness[0.001` + 0.05` thick]}, {clr3,
        Thickness[0.001` + 0.01` thick]}}, Axes -> False,
     PlotPoints -> 200, PlotRange -> All, Background -> clr1]]
   , {n, 32}], 4], ImageSize -> 600]

POSTED BY: Vitaliy Kaurov
7 Replies
Hi Sam, I'm sorry for my unclear description... That post is a reply to Vitaliy's last one, I post it just to show a special setting for the web app he mentioned.
POSTED BY: Silvia Hao
Don’t mean to interrupt this post. The snowflakes are beautiful.

This is just reminding me of fractals. I don’t know much about fractals, but I want to comment and maybe inspire you.

What if the focus was not on one snowflake but many. And not the snowflake alone but if different shaped snowflakes where added together to form a curve? What I am saying is the snowflake is beautiful, but when you add the geometry of the snowflakes (like and different shape) you get a curve.

For example I used angles to define this ellipse (an ellipse is a curve). I recommend using the snowflakes (like and different shape) to create a curve. It would be a curve that only calculus describes now.

I am unsure of the way to approach, but there is more to the snow flake than its beauty. It may produce another beautiful curve. Both 2D and 3D.

I am not sure how to exactly simplify this into an equation. Or where to start. I just have an idea: use like or different shaped snowflakes to explain a curve.

It is like in drafting in taking a known curve and fitting it to something that is irregular and appears to have no pattern. Someone would be doing derivatives to find a curve, but you would have a simple approach to add to snowflakes together.

I can see if I confused you. I will try and see if I can develop the idea further. The snowflakes are just awesome and I don’t want to ruin your presentation with an uncanny idea.
POSTED BY: Bobby Joe Snyder
I really didn’t explain this as clearly as needed because I see that no one commented. I will explain again to get some feedback.

The picture I posted above is an orthogonal view of the snowflake. We learn in art classes that every object is a collection of basic shapes. So what I am describing is nothing new it is just an observation.

From the little I know of 3D modeling when designing something organic or living you want smooth shapes because in nature shapes are naturally smooth. I can’t remember the term but in 3D modeling when you mesh the geometry of the polygons into attached curves it is much easier to work with the shape.

So my observation is that we should be using ellipses to mesh together a 3D shape as a map has contour lines. Again this is nothing new, but what could be new is finding an equation that would define the polygons described earlier into mathematical terms other than just drawing a 3D model by sight alone. Obviously this would be a good use of Mathematica.

But what I am saying is that these 2 and 3D snowflakes have already accomplished this. Take another look at the picture I posted. It is made up entirely of straight lines. But as the lines map points around the edges it creates an ellipse. If we were drawing a shape we could use ellipses or circles or any circular function to function as a contour line on a map that shows elevation or depression. It would be like measuring lines from a given point then connecting those lines with a French-curve.

But as you change the distances and height of the lines you change the curve. You could make something that was asymmetric; something in a pattern; or an irregular shape that occurs in the natural real World.

But the beauty is it is all composed of measurable straight lines.

I know this is nothing ground breaking or original. I just want to bring it to attention there is a practical use behind this snow-flakes. But I propose that we make diamonds out of lines. But diamonds are all straight cuts. I want to see curves defined both graphically and mathematically and use that knowledge to build 3D models.

I will post another image on how the first image was constructed. It is straight line that forms an ellipse, but the ellipse could be an orthogonal view of a snowflake.

Again I realize this is already accomplished by 3D modeling programs, but I see potential here even if it is only a simple observation. In a drawing class I took once, orthogonal views of 3D curves could only be shown by a curved line in 2 views and a 3 view with a line or curve. I know 3D programs have more techniques, but it is a time consuming process and relies on some complex figuring on the computer program. I simple propose to simplify it with elementary mathematics.


http://www.constructorscorner.net/images/e_ellipse/eefig6.gif
POSTED BY: Bobby Joe Snyder
@Silvia, what a wonderful job with rotation, thank you! It reminded me of another app I've seen on the web, that implements beautiful 3D rotation (se below). I think their idea is to rotate each band of hexagons separately around a random 3D axis. I hope I will find some time to implement this in Wolfram Language.

POSTED BY: Vitaliy Kaurov
@Vitaliy That is a beautiful kaleidoscope! I'm sure we can do better in Wolfram Language. And try a coordinate-grid-like setting in that app, you'll see the 3D rotation there isn't random emoticon :

POSTED BY: Silvia Hao
Silvia, your version of kaleidoscope looks great! Did you mean to also post the code for it? I'd love to see how it is made.
POSTED BY: Sam Carrettie
I made a modified version based on your codeemoticon
 Manipulate[
            Module[{n, ?set, basePts, nodePts},
                   
                   n           = RandomInteger[{1, 10}] &@trgr;
                   ?set        = RandomReal[2 ?, n];
                   basePts     = MapThread[#1 Exp[{1, -1} #2 I ?] &,
                                           {RandomReal[{-1, 1}, n], ?set}
                                          ] // MapAt[Reverse, #\[Transpose], 2] & // Flatten;
                   nodePts     = Flatten[{Exp[I (2 ?)/fold Range[fold]]}\[Transpose].{basePts}];
                  
                  Graphics[{
                            EdgeForm[Directive[White, Opacity[.8]]],
                            FaceForm[Directive[White, Opacity[.4]]],
                            White,
                            Polygon[Through[{Re, Im}[#]] & /@ nodePts]
                           }, Background -> Black, ImageSize -> {400, 400}]
                 ],
           {trgr, 0, 1}, {{fold, 6}, 3, 10, 1}]


POSTED BY: Silvia Hao
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