3 ms·
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
by sgtnoodle 6y ago
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.
- yarcob 6y ago> Do you have a notion of how the code actually computes bouyancy? 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.