Message Boards Message Boards

14
|
56153 Views
|
5 Replies
|
32 Total Likes
View groups...
Share
Share this post:

t * sin (t) ? Christmas tree - exploring a famous Reddit discussion

Posted 11 years ago


![enter image description here][1]

I noticed that a [2] about programming a lighted Christmas Tree from a simple equation

t*Snt

became very popular on Reddit. It is connected to a [3] a programmer developed. I thought how fast we can make it with Wolfram language ? Here is the result with slight flickering ;-) Note a very special care needs to be paid to the dimming of the lights at a larger distances, and pretty shadowing.

- Function f(t, f) is rescaling sampling rate of driving parameter t of parametric curve so points are distributed uniformly. f is basically phase shift.

- Parameter PD is just average distance between points

This .GIF file has 100 frames. Enjoy! 

PD = .5; s[t_, f_] := t^.6 - f;
dt[cl_, ps_, sg_, hf_, dp_, f_] := {PointSize, Hue[cl, 1, .6 + sg .4 Sin[hf s[t, f]]], 
Point[{-sg s[t, f] Sin[s[t, f]], -sg s[t, f] Cos[s[t, f]], dp + s[t, f]}]};
frames = ParallelTable[
 
Graphics3D[Table[{dt[1, .01, -1, 1, 0, f], dt[.45, .01, 1, 1, 0, f], 
dt[1, .005, -1, 4, .2, f], dt[.45, .005, 1, 4, .2, f]}, {t, 0, 200, PD}],
 
ViewPoint -> Left, BoxRatios -> {1, 1, 1.3}, ViewVertical -> {0, 0, -1}, 
ViewCenter -> {{0.5, 0.5, 0.5}, {0.5, 0.55}}, Boxed -> False, 
PlotRange -> {{-20, 20}, {-20, 20}, {0, 20}}, Background -> Black],
 
{f, 0, 1, .01}];

Export["tree.gif", frames]


[1]: https://community.wolfram.com/c/portal/getImageAttachment?filename=tree.gif&userId=11733
[2]: http://redd.it/1tswai
[3]: https://github.com/anvaka/atree
POSTED BY: Vitaliy Kaurov
5 Replies
Beautiful.  The shading solution, especially with the subtle differences between large and small points, is very elegant.
POSTED BY: BoB LeSuer
Beautiful tree!
A festoon lamp ornamented one emoticon

 PD = .5;
 s[t_, f_] := t^.6 - f
 dt[cl_, ps_, sg_, hf_, dp_, f_, flag_] :=
  Module[{sv, basePt},
         {PointSize[ps],
          sv = s[t, f];
          Hue[cl (1 + Sin[.02 t])/2, 1, .3 + sg .3 Sin[hf sv]],
          basePt = {-sg s[t, f] Sin[sv], -sg s[t, f] Cos[sv], dp + sv};
          Point[basePt],
         If[flag,
            {Hue[cl (1 + Sin[.1 t])/2, 1, .6 + sg .4 Sin[hf sv]], PointSize[RandomReal[.01]],
             Point[basePt + 1/2 RotationTransform[20 sv, {-Cos[sv], Sin[sv], 0}][{Sin[sv], Cos[sv], 0}]]},
            {}]
        }]

frames = ParallelTable[
                       Graphics3D[Table[{
                                         dt[1, .01, -1, 1, 0, f, True], dt[.45, .01, 1, 1, 0, f, True],
                                         dt[1, .005, -1, 4, .2, f, False],
                                         dt[.45, .005, 1, 4, .2, f, False]},
                                        {t, 0, 200, PD}],
                                  ViewPoint -> Left, BoxRatios -> {1, 1, 1.3},
                                  ViewVertical -> {0, 0, -1},
                                  ViewCenter -> {{0.5, 0.5, 0.5}, {0.5, 0.55}}, Boxed -> False,
                                  PlotRange -> {{-20, 20}, {-20, 20}, {0, 20}}, Background -> Black],
                       {f, 0, 1, .01}];

Export["tree.gif", frames]


POSTED BY: Silvia Hao
Silvia, this is absolutely stunning. To me it gives a perfect feel of reflective flickering.
POSTED BY: Vitaliy Kaurov
Great work! thanks for sharing!
POSTED BY: Max Sakharov

Beautiful! Absolutely a damn good presentation and good work.

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