Draw an iceberg and see how it would float in water
81–90 of 179 posts
Re: Draw an iceberg and see how it would float in water
#82Draw 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.
Re: Draw an iceberg and see how it would float in water
#83I 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.
Re: Draw an iceberg and see how it would float in water
#84Re: Draw an iceberg and see how it would float in water
#85I 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.
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 mas…
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.
Re: Draw an iceberg and see how it would float in water
#86I 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
Re: Draw an iceberg and see how it would float in water
#87Earlier quoted context omitted.
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 mas…
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 t…
Re: Draw an iceberg and see how it would float in water
#88Somehow I am wiling to bet that penis will be found to be the most commonly drawn shape.
Re: Draw an iceberg and see how it would float in water
#89Edit: 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
Re: Draw an iceberg and see how it would float in water
#90I 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.