6 ms·
T * sin (t) ≈ Christmas tree (2013)
- dang 7y agoA thread from last year: https://news.ycombinator.com/item?id=18758290 https://news.ycombinator.com/item?id=18758290 Discussed at the time: https://news.ycombinator.com/item?id=6971693 https://news.ycombinator.com/item?id=6971693 Edit: not implying that this is a dupe—I just mention these links for the curious. On HN, reposts don't count as dupes if a year or so has gone by: https://news.ycombinator.com/newsfaq.html https://news.ycombinator.com/newsfaq.html.
- shakna 7y agoThis one [0][1] is probably my favourite variation. [0] https://community.wolfram.com/c/portal/getImageAttachment?filename=tree.gif&userId=93201 https://community.wolfram.com/c/portal/getImageAttachment?fi... [1] Silvia Hao's reply at https://community.wolfram.com/groups/-/m/t/175891 https://community.wolfram.com/groups/-/m/t/175891 (Also, why doesn't it have id attributes for individual replies?)
- vasili111 7y agoFirst idea I read title I thought about Mathematica and first comment is about Mathematica.
- Edmond 7y agoDesmos always has cool stuff: https://www.desmos.com/calculator/9czmkyav8o https://www.desmos.com/calculator/9czmkyav8o
- tdhz77 7y agoIt’s moments like these that I realize I should have perused more math to find my true programming potential. :/ I’ll never be the good without it.
- JadeNB 7y ago> It’s moments like these that I realize I should have perused more math to find my true programming potential. :/ I’ll never be the good without it. It's never too late! I think that this is a good time to roll out: > “The best time to plant a tree was 20 years ago. The second best time is now.” (which I first heard from rabidrat at https://news.ycombinator.com/item?id=12204797 https://news.ycombinator.com/item?id=12204797).
- jonplackett 7y agoAnyone have any good resources they’d recommend having done this?
- JadeNB 7y agoHN has a wealth of suggestions on this: https://hn.algolia.com/?q=learning+math https://hn.algolia.com/?q=learning+math The top links that come up all look interesting to me at first glance, but I am a mathematician by training rather than a programmer, so I can't say for sure.
- anvaka 7y agoI think if you find passion that needs math, you'll get your math to solid level too. I'm personally never was good at math, so I want to see how it looks. That Christmas tree took me probably a week to build, and for someone it is likely a 10-20 minutes project. Anyway, this curiosity motivates me to learn and build more. Hope it would work for you too!
- JadeNB 7y ago> I think if you find passion that needs math, you'll get your math to solid level too. This is an excellent point! There's no surer way not to motivate yourself to learn something than to think "maybe I'll use this one day" (or at least that's how it works for me); there's no surer path to lasting motivation to learn something than thinking that it'll be useful to address my current problem. (And then, once you get started learning it, often you'll find you get so excited that you go far beyond what you actually need–and that's fantastic!)
- jeffrallen 7y agoWhat kind of ingrate files an issue on a Christmas present?
- majewsky 7y agoI'm always grateful for all issues, on all repos, if the intention is to genuinely improve the project.
- wrigby 7y agoI usually agree, but two of the three open issues should really just be PR's :\ ... After typing that, I realized that this comment should actually just be a PR[1]. 1: https://github.com/anvaka/atree/pull/14 https://github.com/anvaka/atree/pull/14
- city41 7y agoI prefer people open issues before sending in PRs. I also always open an issue before creating a PR. It's possible the maintainer has different ideas/context I'm not aware of. You just never know. Surprise PRs can be disappointing for both parties if the maintainer decides to turn them down.
- wrigby 7y agoOh, that's a really good point! My approach is mostly shaped by my company's culture (which is definitely not one-size-fits-all): if it's a quick thing to code up, I prefer submitting it as a PR with an [RFC] prefix (I've re-titled my PR to include that), so the maintainer knows I'm not too tied to it. I'll probably lean towards opening issues before PR's in the future though - thanks!
- majewsky 7y agoThe problem with one-line PRs is that Github forces you to fork the repo first, but I don't want to litter my repository list with forks for one-off contributions.
- adamnemecek 7y agoIf this interests you, you should check out the bivector community https://bivector.net/ https://bivector.net/ Join the discord https://discord.gg/vGY6pPk https://discord.gg/vGY6pPk. Check out a demo https://observablehq.com/@enkimute/animated-orbits https://observablehq.com/@enkimute/animated-orbits
- anvaka 7y agoHey, author of the project and the 2013 post here. Just wanted to wish everyone amazing holidays! Thank you for love and shares :D PS: More projects since 2013 can be found here: https://twitter.com/search?q=from%3Aanvaka%20min_retweets%3A20&src=typed_query https://twitter.com/search?q=from%3Aanvaka%20min_retweets%3A... - hope you enjoy it.
- harshreality 7y agoThat vector field one is really neat. https://anvaka.github.io/fieldplay/?cx=-0.4690500000000002&cy=0.3672500000000001&w=15.8023&h=15.8023&dt=0.01&fo=0.998&dp=0.009&cm=1&vf=%2F%2F%20p.x%20and%20p.y%20are%20current%20coordinates%0A%2F%2F%20v.x%20and%20v.y%20is%20a%20velocity%20at%20point%20p%0Avec2%20get_velocity%28vec2%20p%29%20%7B%0A%20%20vec2%20v%20%3D%20vec2%280.%2C%200.%29%3B%0A%0A%20%20%2F%2F%20change%20this%20to%20get%20a%20new%20vector%20field%0A%20%20v.x%20%3D%200.2%20*%20%28%20p.y*p.y*p.y%20-%20p.x*p.x%20-%20p.y*p.y%20%2B%20p.y*p.x%20-%20p.x*p.x*p.x%20%29%3B%0A%20%20v.y%20%3D%20-0.2%20*%20%28p.y*p.y*p.x%20%20-%20p.y%20-%20p.x%20%29%3B%0A%0A%20%20return%20v%3B%0A%7D&code=%2F%2F%20p.x%20and%20p.y%20are%20current%20coordinates%0A%2F%2F%20v.x%20and%20v.y%20is%20a%20velocity%20at%20point%20p%0Avec2%20get_velocity%28vec2%20p%29%20%7B%0A%20%20vec2%20v%20%3D%20vec2%280.%2C%200.%29%3B%0A%0A%20%20%2F%2F%20change%20this%20to%20get%20a%20new%20vector%20field%0A%20%20v.x%20%3D%200.2%20*%20%28%20p.y*p.y*p.y%20-%20p.x*p.x%20-%20p.y*p.y%20%2B%20p.y*p.x%20-%20p.x*p.x*p.x%20%29%3B%0A%20%20v.y%20%3D%20-0.2%20*%20%28p.y*p.y*p.x%20%20-%20p.y%20-%20p.x%20%29%3B%0A%0A%20%20return%20v%3B%0A%7D https://anvaka.github.io/fieldplay/?cx=-0.4690500000000002&c...
- anvaka 7y agoThank you! Amazes me how some people use it creatively to teach ordinary differential equations https://twitter.com/sxpmaths/status/1192079061025263616?s=19 https://twitter.com/sxpmaths/status/1192079061025263616?s=19
- ivalm 7y agoX-mas field: https://anvaka.github.io/fieldplay/?cx=12.9055&cy=-22.44975&w=138.3584&h=138.3584&dt=0.01&fo=0.998&dp=0.009&cm=3&vf=%2F%2F%20p.x%20and%20p.y%20are%20current%20coordinates%0A%2F%2F%20v.x%20and%20v.y%20is%20a%20velocity%20at%20point%20p%0Avec2%20get_velocity%28vec2%20p%29%20%7B%0A%20%20vec2%20v%20%3D%20vec2%280.%2C%200.%29%3B%0A%20%20%0A%20%20%2F%2F%20change%20this%20to%20get%20a%20new%20vector%20field%0A%20%20v.x%20%3D%20abs%2810.-p.y%29*sin%28p.y*10.%29*sign%28p.x%29%3B%0A%20%20v.y%20%3D%20-1.%3B%0A%0A%20%20return%20v%3B%0A%7D&code=%2F%2F%20p.x%20and%20p.y%20are%20current%20coordinates%0A%2F%2F%20v.x%20and%20v.y%20is%20a%20velocity%20at%20point%20p%0Avec2%20get_velocity%28vec2%20p%29%20%7B%0A%20%20vec2%20v%20%3D%20vec2%280.%2C%200.%29%3B%0A%20%20%0A%20%20%2F%2F%20change%20this%20to%20get%20a%20new%20vector%20field%0A%20%20v.x%20%3D%20abs%2810.-p.y%29*sin%28p.y*10.%29*sign%28p.x%29%3B%0A%20%20v.y%20%3D%20-1.%3B%0A%0A%20%20return%20v%3B%0A%7D https://anvaka.github.io/fieldplay/?cx=12.9055&cy=-22.44975&...
- rvz 7y ago> HNers: Ooooh! Nice mathematical Christmas tree! Great for learning for the next Algorithms interview. > Everyone: A Christmas Tree! Merry Christmas! > Me: While it’s always nice to see articles like this on HN, I’m afraid that on this occasion I’m partying with friends on Christmas Day. So for today it’s a meh.
- cookie_monsta 7y agoIf you're partying with friends why are you posting on the internet?
- jsjohnst 7y agoMust be a boring party I guess...
- xg15 7y agoDumb question: In the code[1], the requestAnimationFrame() function is overwritten with a custom implementation using setTimeout(). From my understanding, this is done unconditionally, even if the browser provides the function (the reason is not a polyfill but having better control over the frame rate). However, wasn't the whole idea of requestAnimationFrame() that it provides better timing guarantees than setTimeout()? So wouldn't overwriting with setTimeout kind of defeat the purpose of using it? [1] https://github.com/anvaka/atree/blob/58680a99113cc40cd07c3716dd81491c0f263486/index.js#L140 https://github.com/anvaka/atree/blob/58680a99113cc40cd07c371...
- jagged-chisel 7y agoOverridden, overriding
- techbio 7y agoIt’s Christmas, so being generous, “overwritten” applies by the third definition here (https://www.dictionary.com/browse/overwritten https://www.dictionary.com/browse/overwritten) Also, conferring correct usage, ie. actionable information, may be a gift as well, as the fourth definition here (https://www.dictionary.com/browse/overridden https://www.dictionary.com/browse/overridden) I did not find either on (http://catb.org/jargon/html/ http://catb.org/jargon/html/)
- jagged-chisel 7y agoLanguage evolves and changes over time. I don't know whether the popular/common usage for the intended meaning (provide an alternative implementation of a function or method) has begun using "overwritten," but I'd argue that the underlying runtime implementation matters. Typically, one's own implementations doesn't have the ability to literally overwrite the original - the original exists in some place and continues to exist in that place. You can point original symbols at a new implementation, but that old implementation isn't "overwritten" in memory. In OO runtimes, you can override in a subclass (but not overwrite), and the super class implementation is still right there, available as needed. In the discussed case, if anything is truly "overwritten," it's the value (pointer?) at the symbol "requestAnimationFrame," but I'm doubting that's even that case - I'd wager (without being a deep JS expert) that the original is available in another scope. Even given all that, if popular usage wants to go with "overwritten," fine - I'm not a linguistic purist.
- Anon84 7y agoAnd in (quick and dirty) Python, with matplotlib: import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = fig.gca(projection='3d') theta = np.linspace(-4 * np.pi, 4 * np.pi, 100) r = 4*np.pi+theta z = -r x = r * np.cos(theta) y = r * np.sin(theta) ax.plot(x, y, z, 'g*') r2 = 4*np.pi+theta+np.pi/2 z2 = -r2+np.pi x2 = r * np.cos(theta+np.pi/2) y2 = r * np.sin(theta+np.pi/2) ax.plot(x2, y2, z2, 'r*') ax.scatter3D(0, 0, 5, color='gold', s=200, marker="d") ax.axis('off') :)
- jshprentz 7y agoAdd this line at the bottom to show the tree: plt.show()
- deleted 7y ago[deleted]
- addictedtohn 7y agoa GLSL vertex shader version https://www.vertexshaderart.com/art/uDBqerAHTiHEjQMdR https://www.vertexshaderart.com/art/uDBqerAHTiHEjQMdR more of them https://www.vertexshaderart.com/art/rBjrdN2CvsneEkgEk https://www.vertexshaderart.com/art/rBjrdN2CvsneEkgEk and yet another Christmas themed one https://www.vertexshaderart.com/art/23ezRZjpZK82TqNJr https://www.vertexshaderart.com/art/23ezRZjpZK82TqNJr
- twiceaday 7y agoHere is my take on it in ~140 characters of Javascript: https://www.dwitter.net/d/16973 https://www.dwitter.net/d/16973
- basicplus2 7y agoWhy not progressively reduce the angle to the cone's surface to keep the angle to horizontal the same all the way up?
- bilekas 7y agoI love this place.