# \[GIF\] Coalesce (Deforming an isometric pattern)

**URL:** <https://community.wolfram.com/t/gif-coalesce-deforming-an-isometric-pattern/8274>\
**Category:** Staff Picks\
**Tags:** computational-arts, geometry, graphics-and-visualization, staff-pick, computational-humanities\
**Created:** [April 3, 2016, 10:59pm UTC](https://community.wolfram.com/t/gif-coalesce-deforming-an-isometric-pattern/8274 "2016-04-03T22:59:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![claytonshonkwiler](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/claytonshonkwiler/32/24940_2.png) [@claytonshonkwiler](https://community.wolfram.com/u/claytonshonkwiler)\
**Post date:** [April 3, 2016, 10:59pm UTC](https://community.wolfram.com/t/gif-coalesce-deforming-an-isometric-pattern/8274/1 "2016-04-03T22:59:32Z")

</div>

![joints25c.gif](https://global.discourse-cdn.com/wolfram/original/3X/f/3/f35f57f87a0fde3c7da391889a4310ae7ef8bb94.gif)

**Coalesce**

Continuing with the theme of selectively breaking and re-forming a tiling pattern ( [1](https://wolfram.discourse.group/t/8227/1) , [2](https://wolfram.discourse.group/t/8247/1) , [3](https://wolfram.discourse.group/t/8269/1) ), though this time without any rotation.

Here’s the (very slow) code:

```
DynamicModule[{BasicTileCoords, f, cols, centerpoint, ψ, layering}, 
 BasicTileCoords = {{0, -1}, {0, 0}, {Sqrt[3]/2, 1/2}, {Sqrt[3]/2, 0}, {Sqrt[3]/4, -1/4}, {Sqrt[3]/4, -3/4}};
 cols = ColorData["BlueGreenYellow"] /@ Range[1, 0, -1/4];
 f = 3 Piecewise[{{0, # < 0}, {1/2 - 1/2 Cos[#], 0 <= # < π}, {1, # >= π}}] &;
 layering = Append[Riffle[Reverse[Range[5]], -Reverse[Range[5]]], 0];
 Manipulate[
  Graphics[{EdgeForm[Directive[JoinForm["Round"], cols[[4]], Thickness[.006]]], 
    Table[
     {centerpoint = {3 Sqrt[3]/4 i, 3/2 j + (-1)^i*3/8};
      ψ = f[θ - π/(3 Sqrt[7]) Norm[centerpoint - {0, 3/8}]];
      FaceForm[Directive[cols[[t]]]], 
      Polygon[centerpoint + # & /@ (RotationMatrix[2 π t/3].(ψ {Sqrt[3]/4, -1/4} + #) & /@ BasicTileCoords)]}, 
      {j, layering}, {i, layering}, {t, 1, 3}]}, 
   PlotRange -> {{-5, 5}, {-5 + 3/8, 5 + 3/8}}, Background -> cols[[5]], ImageSize -> 540],
{θ, 0., 2 π}]
 ]

```

---

<div class="post-metadata">

**Author:** ![wolframcommunity](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/wolframcommunity/32/8335_2.png) [@wolframcommunity](https://community.wolfram.com/u/wolframcommunity)\
**Post date:** [April 4, 2016, 3:31pm UTC](https://community.wolfram.com/t/gif-coalesce-deforming-an-isometric-pattern/8274/2 "2016-04-04T15:31:06Z")

</div>

![2015-11-02_10-07-11.png](https://global.discourse-cdn.com/wolfram/original/3X/5/0/50e59c9ead62f729e7130d3ea1482555a75602b6.png)

- another post of yours has been selected for the [Staff Picks](http://community.wolfram.com/content?curTag=staff+picks) group, congratulations !

We are happy to see you at the tops of the [“Featured Contributor” board](http://wolfr.am/featured). Thank you for your wonderful contributions, and please keep them coming!

---

<div class="post-metadata">

**Author:** ![marinashchitova](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/marinashchitova/32/13982_2.png) [@marinashchitova](https://community.wolfram.com/u/marinashchitova)\
**Post date:** [April 4, 2016, 3:36pm UTC](https://community.wolfram.com/t/gif-coalesce-deforming-an-isometric-pattern/8274/3 "2016-04-04T15:36:45Z")

</div>

Very beautiful! The simplicity of underlying translation contrasts so much the visual complexity, contrasts are dramatic elements in art!

---

<div class="post-metadata">

**Author:** ![claytonshonkwiler](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/claytonshonkwiler/32/24940_2.png) [@claytonshonkwiler](https://community.wolfram.com/u/claytonshonkwiler)\
**Post date:** [April 4, 2016, 4:03pm UTC](https://community.wolfram.com/t/gif-coalesce-deforming-an-isometric-pattern/8274/4 "2016-04-04T16:03:14Z")

</div>

[@Marina Shchitova](http://community.wolfram.com/web/marinashchitova) Thanks. It took me forever to come up with the idea for this, so I’m glad you think it works.

---

<div class="post-metadata">

**Author:** ![jfultz](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/jfultz/32/20473_2.png) [@jfultz](https://community.wolfram.com/u/jfultz)\
**Post date:** [April 4, 2016, 4:29pm UTC](https://community.wolfram.com/t/gif-coalesce-deforming-an-isometric-pattern/8274/5 "2016-04-04T16:29:35Z")

</div>

If you pre-compute everything except for the bits that depend upon the `Manipulate` variable, it gets much faster. This code is not so pretty. I didn’t try to make the most elegant refactoring that does precomputation…just one that I could easily refactor starting from your code. But, on my computer, the slider pretty much works in real time.

```
DynamicModule[{BasicTileCoords, f, cols, centerpoint, ψ, 
  layering, pts1, pts2, pts3, n}, 
 BasicTileCoords = {{0, -1}, {0, 0}, {Sqrt[3]/2, 1/2}, {Sqrt[3]/2, 
    0}, {Sqrt[3]/4, -1/4}, {Sqrt[3]/4, -3/4}};
 cols = ColorData["BlueGreenYellow"] /@ Range[1, 0, -1/4];
 f = 3 Piecewise[{{0, # < 0}, {1/2 - 1/2 Cos[#], 
       0 <= # < π}, {1, # >= π}}] &;
 layering = Append[Riffle[Reverse[Range[5]], -Reverse[Range[5]]], 0];
 {pts1, pts2, pts3} = 
  Table[centerpoint = {3 Sqrt[3]/4 i, 3/2 j + (-1)^i*3/8};
   ψ = f[n - π/(3 Sqrt[7]) Norm[centerpoint - {0, 3/8}]];
   N[centerpoint + # & /@ (RotationMatrix[
          2 t π /3].(ψ {Sqrt[3]/4, -1/4} + #) & /@ 
       BasicTileCoords)], {t, 1, 3}, {j, layering}, {i, layering}];
 Manipulate[
  Graphics[{EdgeForm[
     Directive[JoinForm["Round"], cols[[4]], Thickness[.006]]],
    {{FaceForm[Directive[cols[[1]]]], Polygon[Dynamic[Flatten[pts1 /. n -> θ, 1]]]},
       {FaceForm[Directive[cols[[2]]]], Polygon[Dynamic[Flatten[pts2 /. n -> θ, 1]]]},
       {FaceForm[Directive[cols[[3]]]], Polygon[Dynamic[Flatten[pts3 /. n -> θ, 1]]]}}}, 
   PlotRange -> {{-5, 5}, {-5 + 3/8, 5 + 3/8}}, 
   Background -> cols[[5]], ImageSize -> 540], {θ, 0., 
   2π}]]

```

---

<div class="post-metadata">

**Author:** ![pleasureoffiguring](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/pleasureoffiguring/32/18977_2.png) [@pleasureoffiguring](https://community.wolfram.com/u/pleasureoffiguring)\
**Post date:** [April 4, 2016, 4:33pm UTC](https://community.wolfram.com/t/gif-coalesce-deforming-an-isometric-pattern/8274/6 "2016-04-04T16:33:32Z")

</div>

Very nicely done! I was so impressed that I felt compelled to simplify the code slightly (though unfortunately it is only slightly faster than the original.):

```
Manipulate[Graphics[{EdgeForm[Directive[JoinForm["Round"], cols[[4]], Thickness[.006]]],
                     Flatten[Table[Block[{centerpoint = {3 Sqrt[3]/4 i, 3/2 j + (-1)^i 3/8}, ψ, tr},
                                          ψ = 3 Haversine[Clip[θ - π/(3 Sqrt[7]) EuclideanDistance[centerpoint, {0, 3/8}], {0, π}]];
                                          tr = Composition[TranslationTransform[centerpoint],
                                                           RotationTransform[2 π t/3], 
                                                           TranslationTransform[ψ {Sqrt[3]/4, -1/4}]];
                                         {FaceForm[cols[[t]]], Polygon[tr[BasicTileCoords]]}],
                                   {j, layering}, {i, layering}, {t, 1, 3}], 2]},
                    Background -> cols[[5]], ImageSize -> 540, PlotRange -> {{-5, 5}, {-5 + 3/8, 5 + 3/8}}],
           {θ, 0, 2 π}, Initialization :> (BasicTileCoords = 
                                           N[{{0, -1}, {0, 0}, {Sqrt[3]/2, 1/2}, {Sqrt[3]/2, 0}, {Sqrt[3]/4, -1/4}, {Sqrt[3]/4, -3/4}}, 20]; 
                                           cols = ColorData[{"BlueGreenYellow", "Reverse"}] /@ Subdivide[4]; 
                                           layering = Flatten[Append[Outer[Times, Range[5, 1, -1], {1, -1}], 0]];)]

```

---

<div class="post-metadata">

**Author:** ![claytonshonkwiler](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/claytonshonkwiler/32/24940_2.png) [@claytonshonkwiler](https://community.wolfram.com/u/claytonshonkwiler)\
**Post date:** [April 4, 2016, 5:17pm UTC](https://community.wolfram.com/t/gif-coalesce-deforming-an-isometric-pattern/8274/7 "2016-04-04T17:17:26Z")

</div>

[@John Fultz](http://community.wolfram.com/web/jfultz) Ah, smart! That’s way faster. Thanks!

---

<div class="post-metadata">

**Author:** ![claytonshonkwiler](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/claytonshonkwiler/32/24940_2.png) [@claytonshonkwiler](https://community.wolfram.com/u/claytonshonkwiler)\
**Post date:** [April 4, 2016, 5:26pm UTC](https://community.wolfram.com/t/gif-coalesce-deforming-an-isometric-pattern/8274/8 "2016-04-04T17:26:06Z")

</div>

[@J. M.](http://community.wolfram.com/web/pleasureoffiguring) Oh, right, `Haversine[Clip[#,{0,?}]]&` is definitely much nicer than my `f`. Thanks!

---

<div class="post-metadata">

**Author:** ![Vitaliyk](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/vitaliyk/32/45591_2.png) [@Vitaliyk](https://community.wolfram.com/u/Vitaliyk)\
**Post date:** [April 6, 2016, 3:31pm UTC](https://community.wolfram.com/t/gif-coalesce-deforming-an-isometric-pattern/8274/9 "2016-04-06T15:31:47Z")

</div>

Clayton, [Wolfram Facebook post](https://www.facebook.com/wolframresearch/posts/10153704218123795) with this art currently got 120 shares and almost 300 likes, - very popular! Very lovely!

---

<div class="post-metadata">

**Author:** ![claytonshonkwiler](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/claytonshonkwiler/32/24940_2.png) [@claytonshonkwiler](https://community.wolfram.com/u/claytonshonkwiler)\
**Post date:** [April 7, 2016, 3:27am UTC](https://community.wolfram.com/t/gif-coalesce-deforming-an-isometric-pattern/8274/10 "2016-04-07T03:27:22Z")

</div>

[@Vitaliy Kaurov](http://community.wolfram.com/web/vitaliyk) Oh wow. Impressive!
