Live data from Hacker News

Draw an iceberg and see how it would float in water

joshdata.me

171–179 of 179 posts

Re: Draw an iceberg and see how it would float in water

#172
post #71
post #9

I get interesting results if I draw a figure 8 (or a figure ∞). I wonder if it's treating one of the lobes as having negative density.

I spent... longer than I should have trying to take advantage of this bug to recreate a stable version of the stereotypical tall iceberg that the original tweet was complaining about. https://imgur.com/a/WG6D0RJ

I made a vertical one just by making it very thin: https://gliggy.github.io/tallandthin.png

Re: Draw an iceberg and see how it would float in water

#173
post #153

Earlier quoted context omitted.

It's just potential energy minimization. A tall thin iceberg will float on its size in 2D or 3D.

That’s assuming the 2D representation is representative of near uniform density. In 2D an I-beam and and a solid beam look identical, but they don’t represent the same amount of mass for potential energy minimization. Play with 3D shapes and you could get identical 2D cross sections to float in arbitrary orientations.

You can but only under very arbitrary situations that aren't common in real life. And if you're assuming it's not hollow and has constant density, then I doubt there's any way to make such an iceberg except if you look at it from one specific angle: looking from the side should give it away. Yet nearly every image of an iceberg seems to show them in that way.

Re: Draw an iceberg and see how it would float in water

#174
post #149

Earlier quoted context omitted.

And drawing them at the bottom yields very different results than partially or fully above the surface!

I think they fixed this - today I can’t make the same shape, it just drops one of the triangles.

Yeah, they added a sun, too.

Re: Draw an iceberg and see how it would float in water

#175
post #173
post #153

Earlier quoted context omitted.

That’s assuming the 2D representation is representative of near uniform density. In 2D an I-beam and and a solid beam look identical, but they don’t represent the same amount of mass for potential energy minimization. Play with 3D shapes and you could get identical 2D cross sections to float in arbitrary orientations.

You can but only under very arbitrary situations that aren't common in real life. And if you're assuming it's not hollow and has constant density, then I doubt there's any way to make such an iceberg except if you look at it from one specific angle: looking from the side should give it away. Yet nearly every image of an iceberg seems to show them in that way.

That’s a different question. In practice floating icebergs are often at a local minima not the global minima. They can be at very unstable orientations in calm seas. The constant melting process promotes instability.

Re: Draw an iceberg and see how it would float in water

#177
post #141

Earlier quoted context omitted.

What parts of jquery in particular?

I think the Node querySelector $('selector'), attaching event listeners, getting and setting element width/height

My script template includes some things like `var $=a=>{return document.querySelector(a)}`, `...prototype.evt=(a,b)=>{var e=this.addEventListener(a,b);this.events=this.events||[];this.events.push(e);return e}` and a few other shortcuts. I generally do a mass search and replace to remove them before saving as sometimes i modify them, and conflicting userscripts isn't fun.

Re: Draw an iceberg and see how it would float in water

#178
post #177
post #141

Earlier quoted context omitted.

I think the Node querySelector $('selector'), attaching event listeners, getting and setting element width/height

My script template includes some things like `var $=a=>{return document.querySelector(a)}`, `...prototype.evt=(a,b)=>{var e=this.addEventListener(a,b);this.events=this.events||[];this.events.push(e);return e}` and a few other shortcuts. I generally do a mass search and replace to remove them before saving as sometimes i modify them, and conflicting userscripts isn't fun.

Yes, you can replace basic functionality with a few lines of code, but jQuery has more features.

For example, jQuery.on('') also works with dynamically created elements. If you want that in vanilla JS you have to write more lines a code, I actually created a library/function for this specific use case: https://github.com/Cristy94/dynamic-listener

Post reply on HN