So without any further knowledge about how icebergs should orient and how scientists draw them:
Icebergs in 3D will generally have different mass distributions than the corresponding 2D projections that we are drawing here. For example, there will generally be higher "2D mass density" in the center.
Consequently, it is possible that the scientists "drawing icebergs wrong" are actually right and it just looks/"behaves" wrong in 2D. And even if they're doing it wrong, it's also possible to learn the wrong lessons regarding floating stability from this 2D playground.
I concur! In addition to that, icebergs also probably don't have a unified mass just based on the proportions. Some parts of the iceberg will be snow, others will be very tightly packed snow while others will be just ice, also with different densities.
So the iceberg could very likely float like that when taking into considering 3d space + the random distribution of mass that is different in different parts of the iceberg.
This kind of drawing matches early year mechanical engineering courses.
The generalizations are to add density distributions and the 3rd dimension.
The math generalizes just fine for picking points that are stable. The motion on how it gets there relies on the full Navier Stokes vs the simplifications, so I wouldn't trust that you've actually gotten to the right stability point
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.
I think this was patched just now. On my last visit a few minutes ago the bug still worked, now it removes any larger bits where the lines intersect.
Also, the code has been amended right where this comment is:
// People like to draw shapes with kinks, which results
// in part of the polygon being treated as negative area.
// turf.unkinkPolygon can be used to find the kinks and
// separate the polygon into multiple polygons at the
// kinks, but it's a little fragile and hard to combine
// into a single unkinked polygon. [...]
I'm having so much fun with the before-the-fix version, you can make it "jump" out of the water, if you draw a figure 8 under water, and when the negative lobe is at the top and around 75% of the size of the positive one
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.
I believe it works because the sail consists of negative mass. The overall mass of the boat is therefore lower, but the part of the hull that's under water produces the same amount of bouyancy based on the area of displaced water. Because of the width of the hull, it's a stable equallibrium.
Interestingly, if the sail were to become submerged, it would create negative bouyancy and the boat would sink!
Cool, I stand corrected. I tried with a few triangles of my own but they never stayed upright, but maybe I just suck at drawing and they all started too far off-center to remain in the little "valley" of the stability diagram.
You can create pontoons by circling over the same spot repeatedly. It's like you're concentrating more mass into the same area but reducing the density!
The code must somehow compute bouyancy in a way that reflects the object's arbitrarily complex shape. It's likely carving the object up into some number of smaller primitive objects whose equations for bouyancy are known. In order to make the whole object move as one rigid body, though, it's probably computing force vectors for each primitive, and then summing them together based on the overall object's center of mass and moment of inertia.
My guess is that the object's mass and inertia is calculated in a way that is sensitive to the handedness of the drawing. The code probably takes the absolute value of the result so that right-handed and left-handed drawings both end up with positive mass. When you draw lobes though, the signedness alternates and cancels out, leading to less mass. With even numbers of lobes of near equal size, you end up with near zero mass.
The forces being computed on each primitive are probably representative of that primitive's true mass. Subsequently applying those same forces to a rigid body with significantly less mass therefore results in extreme acceleration. f=ma, f/m=a. f/0=explode.
If you look at the source, you'll see that it doesn't really try to split the path into smaller primitives at all. It uses a simple algorithm (https://stackoverflow.com/a/33852627) to calculate the center of mass, and another algorithm to calculate the area (https://stackoverflow.com/a/33670691).
Both of these algorithms basically sum up the "signed area" of the polygons. This means that if you circle something twice, it'll count twice, and the sign depends on the direction of the winding.
The confusing part is that when the polygon is drawn, it uses the "non-zero winding rule" to determine which part to fill. So the filled parts of the polygons are all parts that contribute non-zero parts to the area (eg. positive, negative, two time positive etc.).
So the weird behaviour is that the physics simulation doesn't use the same rules as the visualisation!
So the nice thing about these algorithms is that it works for arbitrary complex shapes as long as the path has no self-intersections.
If you want to add support for self-intersecting paths, you need to decide how to deal with intersections. Presumably you'd want the physics to match the visualisation, ie. use the non-zero winding rule also for centroid and area calculations. To do that, you would first need to split the polygon into non-intersecting parts, and then calculate the area separately for each part, and then sum up the absolute values of the individual parts.
I annotated a screenshot with winding numbers. You'll see that the filled areas correspond to the parts with non-zero winding numbers, but the physics simulation considers the sign and magnitude.
Thanks for tracking down the actual algorithms! It appears that they work by summing the "signed" areas of half-trapezoids formed between each neighboring pair of vectors and an arbitrary axis line, so I'm going to stand by my claim that the code breaks the polygon up into smaller primitives. :-)
Good catch with the discrepancy between the physics and the visualization. I wonder if there's a way to engineer a cool structure with a lot of invisible mass.
Do you have a notion of how the code actually computes bouyancy? Does it somehow slice the polygon into two at the water line and then compute center and area of both? Once again, it would be interesting to engineer an object that leverages any non-linear behaviors at the water line, perhaps like an object whose mass changes depending on its position and orientation.
Lol, thanks for the info. I was able to engineer an iceberg-boat. The boat is low mass but high bouyancy. If it were to be fully submerged, it would remain partially sunk.
I knew this was happening, but reading it, hey, maybe that's one way to get anti-gravity. Just loop the topology on itself. Obviously commenting in jest, but now I'm intrigued to see if someone has seriously considered this.
One of the theoretical reverse time travel machines I read about in the past involved stabilizing a wormhole first and then dragging it somewhere else, like to the future relative to current time by traveling near light speed with it, so you could get back to the earlier time.
Kip Thorne wrote of something that involved an extreme amount of mass in a spinning cylinder. That kind of mass was imagined to be at a huge scale like harnessing a number of stars and compressing them, iirc.
A device theorized or implemented by Salvatore Pais involves use of superconductors and microwaves to create an effective vacuum, like dragging part of spacetime. It could allow FTL relocation without actual speed. This could also create an area of effectively high masses that could allow time travel, even eventually reverse time travel, under theoretical conditions.
I draw an ice cream cone. First draw the ice cream like you would a cloud. Once connected then continue to draw the cone , such that you draw a V to connect to the ice cream.
If you extend the infinity sideways (easy with touch, hard with mouse) it seems to depend on how many lobes there are. 3, 5, or 7 is stable, 4, 6, or 8 is very unstable.
Given how much the behaviour varies at different angles and in different positions, we can be fairly sure the algorithm used is incorrect even without these odd cases. You can also see odd orientation-dependent behaviours with non-weird shapes.
Symmetric and asymmetric behavior baffles me. Any progressive papers on the independent relationships between infinite limits, finite quantities, and asymmetric phenomenon would be much appreciated from the homestead.
Also, what is the dependent relationship between stable states and non-stable state systems? Is it more simple than thought before?
I tried with a timeglass-like shape. It flew around the map, going in and out of view and eventually setting on/in the water https://i.imgur.com/kcT9elV.jpg
Draw a horizontal line under the water, then return back to its start with a wavy line crossing over the first line repeatedly. Very strange things happen. The first time i tried, it leapt out of the water then flapped around..
To trigger the behavior, it seems the waves need to be "asymmetric" in that if the leftest one is up, the rightest one needs to be down. Otherwise, it seems to behave normally.
It doesn’t tell you what you’re doing or how to do it. It’s just a basic, flexible layer on top of the DOM and doesn’t try to be anything else. There should be more jQueries out there, for all fields.
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
It’s interesting that proponents of a simpler web argue in favor of Jquery for a use case where jquery is in fact very easy to live without. One would almost think dogmatic thinking is involved.
> It’s interesting that proponents of a simpler web argue in favor of Jquery for a use case where jquery is in fact very easy to live without. One would almost think dogmatic thinking is involved.
But to do without it, you will end up rewriting the shortcuts and utility functions that JQuery provides, effectively recreating a project-specific, less-tested and less-supported JQuery.
Are still talking about the jQuery usage in https://joshdata.me/iceberger.html or in general? If the former, then I agree that jQuery was unnecessary here, all API functions used by the author now has appropriate functions shipped natively in the browser runtimes, so using jQuery was actually more work than not (unless the author never used the vanilla API but have used the jQuery API).
junior devs say dumb things about jQuery because they need to build experience and clout in complicated bloatware
fortunately the crypto space is paying well enough these days and all you need is a wallet connect button, without a backend, so devs don't have to deal with this particular elitist bullshit to get hired by someone else anymore
its actually questionable whether you need a frontend to make money right now. I've seen plenty of "dutch auctions" with just the liquidity pools: just gotta deploy a smart contract and give instructions on how to form transactions to it.
I had never considered that "ice cone shaped" icebergs wouldn't be stable. It's obvious in hindsight, if you gave me an ice cube shaped like that I'd never expect it to float upright.
Now every time I'll encounter one of those I'll feel mildly irritated. Sometimes ignorance is bliss.
The algorithm doesn't seem to be complete, it can't handle concave shapes with trapped water or trapped air. But that's probably too much to ask.
Edit: to illustrate the point, this iceberg had trapped air before it stabilized and removed all air, which is physically impossible: https://imgur.com/a/uiaW1qN
on the one hand, this is clearly a 2D simplification of a 3D problem.
on the other... if you imagine your spiral as projecting outward a non-infinite distance, how could it possibly "trap" air? the air would flow toward (and away from) the viewing plane very quickly.
If you draw something in the basic shape of a Y, with two thick arms and one thin arm, my instinct tells me that the two thick arms should end up on the top, with the thin one pointing down into the water. Is that accurate? There's not much jostling in the demo; any of the arms might end up pointing down.
EDIT: You can also pretty easily get something to float in either an M or a W configuration. Now I want a slider for turbulence; I bet some shapes are hard to dislodge from their current orientation and some are easy.
Yes this is pretty cool! It’d be awesome if you could link to the drawings. Though I bet descriptions of most of the images would rhyme with “ice rocks”.
Hum... The most stable position is with the thin arm down, but all three have meta-stability, so what position it ends up on is path-dependent (until you go there and poke it so it rotates really fast).
Hmm... what determines whether an iceberg would flip over? I tried drawing bowl-shaped icebergs, one upright and one upside-down. Both stayed in their general orientation without flipping over.
For many shapes, there are multiple points of stability! If you drew a cross, you'd find that it could stabilize on any two corners.
Stability of a floating object is determined by a "righting arm": A torque produced by the horizontal offset between the object's center of mass, and the center of buoyancy (The center of mass of the portion underwater).
Sometimes, that torque produces "positive stability" -- When the object tilts into the water, the center of buoyancy shifts in a direction that increases the righting arm force and pushes the object back upright.
On the other hand, other shapes produce "negative stability" -- Tilting the object shifts the center of buoyancy in a direction that reduces the righting arm force, so the object flips.
This is why ships are (roughly) square shaped when looking at a cross section: If you visualize a floating box tilting to the right, more of the right side will be underwater. This produces a righting arm force that turns the box back to the left.
The worst case for stability is a circle, since no matter what angle the shape is at, the righting moment is always zero -- There's no horizontal offset between the center of mass and center of buoyancy, so a circle never has a righting force.
When it comes to stability there is a crucial handicap between ships and icebergs. The former have non-uniform mass, so it is possible for a ship's center of mass to be below its center of buoyancy. That's why ships have ballast - it lowers the center of mass relative to the center of buoyancy.
An iceberg is uniform, so its center of buoyancy is always below its center of mass. This makes its stability trickier, as it relies on changes in the shape of the buoyancy to follow the center of mass when disturbed.
A ship is a pendulum, an iceberg is an upright stick balanced on one's nose :)
Good point -- The way I described it really applies to _any_ object floating in water.
I don't have much experience with ship design, but on small boat design you can rely mostly on the geometry of the boat to produce a sufficient righting moment even with a very high center of mass.
Some off-shore speedboats have really incredible self-righting because they've been designed to always have positive stability at all angles. One of my favorite videos of this in action: https://www.youtube.com/watch?v=Y2i1fOJ-itw
The trick is to draw a low-mass object with high displacement, which happens to be possible because of the existence of, uh, anti-iceberg? that has negative mass.
Yes, small boats are often constrained by shallow water, so they cannot have too much ballast not to mention things like bulb-keel. This means the hull needs to be sufficiently broad and flat.
I suspect, based on nothing in particular, that one of those orientations is more stable than the other, but the demo doesn't provide enough turbulence to get from one to the other.
I love the linked twitter page detailing the ... details of floating configurations for icebergs. My old mentor used to talk about how hard it was for the solvers to find stable configurations for floating bodies/structures/rubberDuckies “back in the old days”
Ah well... good times, and watch out for rotations that don’t matter!
So much fun!
I majored in mechanical engineering but I am developing software totally irrelevant with it.
This is reminiscent of what I learned in university. I feel fun and curious about the model for simulating this.
Try drawing the infinity symbol under water - mine jumped out of the water! It even jumped off screen, and ended up like an 8, half submerged, half above water.
My other attempt hit the water/air boundary from below, and bounced back towards the bottom, off screen again, and reappeared in a bit.
There seems to be a bug with figures with boundaries that cross each other. Perhaps there is an issue with determining inside vs outside for the figure.
An infinity symbol drawn so the line crosses itself has issues. If you trace the outside of the symbol, without crossing, it works as expected.
Very cool! It would be nice to use it for showing how a figure bounded by a Zindler curve [1] and with half the density of water will float in water in any position.
Cool. I notice that something dropped from the top accelerates downwards. But something released at the bottom doesn't seem to accelerate noticeably upwards. Even with drag, a bouyant object should accelerate towards the suface, shouldn't it?
There seems to be a bug where in Firefox for Android the page scrolls even when you're drawing in the canvas. This makes it annoying to try and draw relined figures, which often result in horizontal lines.
It's amazing that this kind of simulation can be done so accurately with javascript in a web browser. I have no idea how it was implemented but the computational load must be nontrivial.
I haven't looked at the code but it's likely some out-of-the-box physics engine, many of them available in JS. They often have to employ many more complex physics features. Buoyancy is just one of them. Computationally I'm sure it's complex, but it's made to run at game tickrates, less than the max budget of 16ms at a time.
Icebergs in 3D will generally have different mass distributions than the corresponding 2D projections that we are drawing here. For example, there will generally be higher "2D mass density" in the center.
Consequently, it is possible that the scientists "drawing icebergs wrong" are actually right and it just looks/"behaves" wrong in 2D. And even if they're doing it wrong, it's also possible to learn the wrong lessons regarding floating stability from this 2D playground.