Draw an iceberg and see how it would float in water
joshdata.me
joshdata.me
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.
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.
Play with 3D shapes and you could get identical 2D cross sections to float in arbitrary orientations.
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
And some of them completely disappear!
It flys!
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.
It was one of the grand challenges in the 00's, quietly solved by John Ratcliff. Then a few people solved it after him.
It's a fun algorithm. You basically slice and dice, like chopping a potato, then recombine small parts together based on a heuristic.
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.
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.
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.
Weight force (downward) is determined by the full polygon.
Buyancy force (upward) is determined by the part below the water line.
Lateral/angular motion results from the fact that the forces act on the centroids of the full polygon vs the centroid of the submerged polygon.
The script seems to use a JS library named "turf" to clip the polygon at the water line. Here's the line in the source:
var pp = turf.bboxClip(p, [-Infinity, yZero, Infinity, Infinity]).geometry.coordinates[0];
As far as I can tell, yZero is the water line, and pp is the part of the polygon that is submerged.
(there are about 4 completed saw tooths above the screen)
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!
Any convex shape will tend to minimize the forces due to buoyancy and "horizontal" should always go less deep (or equal for a sphere) than "vertical"
It can be in a local minima of buoyancy without being a global minima. Similar to an un-sharpened pencil balanced on it's end.
To really throw it off and make it stay underwater or hop around, you must be quick to reduce the points and create negative areas via crossover.
But it’s impressive how it lets you draw beyond the boundaries and reacts reasonably.
Best iceberg simulator I’ve ever used. I had fun playing with it for at least ten minutes. I’d go so far as to recommend it for education.
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. [...]> turf.unkinkPolygon=(x)=>x;
Press F12, click 'Console', copy-paste the above one and press Enter.
Even more optimal: https://imgur.com/7gCEJ0T
I've had more extreme versions of this shape teleport off-screen, when starting them under water: https://imgur.com/ymVtTWq
And here's someone holding a balloon: https://imgur.com/8O4rib8
Also, what is the dependent relationship between stable states and non-stable state systems? Is it more simple than thought before?
https://physicstoday.scitation.org/doi/10.1063/PT.3.4373
which in turn links to this paper, E. N. Gilbert's How Things Float, which gives much more detailed mathematical explanation
PDF: http://111.90.145.71/scimag/get.php?doi=10.2307/2325023&key=...
This is a very obvious in retrospect flaw for anybody that has experience in graphic computing, but it's a common gotcha even there.
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 may not be necessary, but the specific tools are't the part that are necessary.
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.
Otherwise I agree with you in general.
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.
Now every time I'll encounter one of those I'll feel mildly irritated. Sometimes ignorance is bliss.
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 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.
Drawing a star is fun.
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.
I like https://en.wikipedia.org/wiki/Simulated_annealing it does not guaranty to find the absolute minimum, it has a few parameters that are difficult to tweak, but I got good results.
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.
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 :)
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.
Ah well... good times, and watch out for rotations that don’t matter!
https://iceberger.boomla.net/?id=0162f6a3c3e7e1e1bde4fade9c1...
Here is a video at 12800x speed :P
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.
The only text I saw "above the fold" was the one above the drawing surface.
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.
I don't have that problem in mobile Chrome.
Other than that, pretty cool!
Can someone summarize how this works?
Is this simply a numerical integration of volume and then some assumptions to compute the buoyant force?
Thanks for putting it together.
Good besides