The red arc describes the upper side of the hull, the blue follows the lower side. The straight green, red and black straight lines are radii for the upper arc. The length of the spindle is 70 meters and the diameter at the center is 8 meters.
I used the Pythagorean formula to generate a formula to compute the radius of the hull from the distance from the bow. That seemed to work fine. The next day I tried to check my work, but being short on sleep my head was full of cotton and I could not make sense of it. Now I think I understand what it's like for people who have a hard time with math. It was like part of my brain was not working. Anyway, I'm doing better today so I took another look at it.
CPU ticks Slices Volume
4 1 3,518.583,772
4 10 1,883.743,261
17 100 1,883.565,830
133 1,000 1,883.565,812
1,339 10,000 1,883.565,812
12,929 100,000 1,883.565,812
131,847 1,000,000 1,883.565,812
1,110,081 10,000,000 1,883.565,81310,897,789 100,000,000 1,883.565,810
The volume is in cubic meters. At one hundred slices we already have the volume to the nearest liter (one one-thousandth of a cubic meter). At one thousand slices we have the volume to down to one cubic centimeter (one milliliter). At ten million slices the last digit starts changing. I suspect we have reached the limit of what can be done with floating point math without taking a closer look at the equations. I'm not going to do that. The nearest cc is close enough for me.
Comma-fication
Big numbers without commas are hard to read, so I spent most of a day working out how to automatically place commas in the output. It made the program four times as long. In some versions of C you can use an apostrophe to tell printf to insert commas, but it wasn't available with the online compiler I used, so I wrote my own routines. And because I wasn't sure if it was working correctly, I wrote another one to verify the first.
I also added some rudimentary command line parsing so you can change the length, beam and number of slices without having to modify the code.
Blog post: Jules Verne - Nautilus
C program source code on github
OnlineGDB IDE (Interactive Development Environment) C compiler
1 comment:
Count how many kegs it takes to fill it with beer.
xoxoxoBruce
Post a Comment