Skip to content

Commit

Permalink
change(/wiki/introduction): omit square-cube law
Browse files Browse the repository at this point in the history
- S.C.-Law is now a footnote.
- Changed heading to a formula.
- Make math voxels only one byte.
- Fix all the math.
- Fix grammar.
  • Loading branch information
Longor1996 committed Sep 29, 2024
1 parent 08e95ea commit c9019c7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
35 changes: 15 additions & 20 deletions content/wiki/introduction/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,44 +172,35 @@ Let me repeat: <b style="color:red">Don't do this.</b>



But you know what isn't complicated, but **extremely important** to know?

## The Square-Cube Law
## Volume = Distance ³

{% figure(class="float", caption="Relationship between Length, Area & Volume.", author="[Cmglee](https://commons.wikimedia.org/wiki/User:Cmglee)", license="[CC-BY-SA-4.0](https://commons.wikimedia.org/wiki/File:Relationship_between_length_and_area_and_volume.svg)") %}https://upload.wikimedia.org/wikipedia/commons/a/ae/Relationship_between_length_and_area_and_volume.svg{% end %}

When dealing with voxels/bloxels and their various algorithms,
you'll quite often be up against the **Square&#8209;Cube&nbsp;Law**:

{% quote(author="[Wikipedia](https://en.wikipedia.org/wiki/Square%E2%80%93cube_law)") %}
When an object undergoes a proportional *increase in size*, its new **surface area** is proportional to the *square* of the multiplier and its new **volume** is proportional to the *cube* of the multiplier.
{% end %}

<div style="clear:both"></div>
A fundamental reality of many voxel algorithms
is that the data they deal with **cubically**[^squarecube].
What does that mean, in practice?

Let's do a tiny bit of math (<small>feel free to grab a calculator</small>):

1. Think of how far into the distance you want to 'see', in meters/voxels.
2. Using that distance, calculate `(D*2)³` to get the visible volume.
3. Assume a voxel takes 64 bits, i.e. 8 bytes of space...
4. ...so multiply the volume by 8 bytes.
5. Divide by `1024` to get it as kilobytes.
6. Divide by `1024`, again, for megabytes.
3. Assume a voxel takes just a single byte of space...
4. Divide by `1024` to get it as kilobytes.
5. Divide by `1024`, again, for megabytes.
- Divide again to get gigabytes, if needed.
7. Look at the amount of memory used.
8. Change the distance and repeat a few times.
6. Look at the amount of memory used.
7. Change the distance and repeat a few times.

{{ volume_memory_calc(id="calculator") }}

{% info_notice(summary="Fun Fact: Planet-sized Volumes") %}
If you solve for the size of the earth (a radius of 6371km), you will get a fun number of roughly **16550 exabyte**... which is more than half of the *entire* contents of the world-wide-web (in ~2024) at about **27000 exabyte**!
If you solve the volume for the size of the earth (a radius of 6371km), you will get a fun number of roughly **2068 exabyte**... which is roughly seven percent of the world-wide-webs *entire* contents (in ~2024), at about **27000 exabyte**!

Luckily, most of any planets volume is unreachable, hidden under the surface,
so it can be treated as if it didn't exist, vastly reducing the needed volume.
{% end %}

While computers these days are pretty darn powerful, **they still have limits**,
and working with voxels can push things there *very* quickly...
and working with voxels can push them there *very* quickly...

- Your RAM may be large (many gigabytes, usually ~4-8 GB),<br/>
but the bits'n'bytes still need to go to/fro the CPU and back.
Expand Down Expand Up @@ -251,3 +242,7 @@ Perhaps [share](/wiki/community) your creation?
## Next

Choosing a programming language!

---

[^squarecube]: <https://en.wikipedia.org/wiki/Square%E2%80%93cube_law>
4 changes: 2 additions & 2 deletions templates/shortcodes/volume_memory_calc.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div id='{{id}}' class='notice info' style='display:none'>
<div style="text-align:center">Interactive <b>Distance ⇒ Memory</b> Calculator</div>
<div style="display:flex;justify-content:center;align-items:center;padding:0.5rem">
<div>(<input type=number required min=16 max=65536 step=16 value=16 style='width:5em;text-align:end;border-radius:5px;border:1px solid grey;font-family:monofont' title='View Distance'>&hairsp;m * 2)³ * 8</div>
<div>(<input type=number required min=16 max=65536 step=16 value=16 style='width:5em;text-align:end;border-radius:5px;border:1px solid grey;font-family:monofont' title='View Distance'>&hairsp; * 2)³</div>
<div>&nbsp;=&nbsp;</div>
<code style='font-weight:bold;text-align:end;min-width:7em;background:#0000007a' title='Memory Usage'>0 kB</code>
</div>
Expand All @@ -26,7 +26,7 @@
}
function put(b, u) {calc_output.innerHTML = b.toFixed(2) + '&hairsp;' + u}
var V = Math.pow(D*2, 3), K = 1024;
var bytes = V * 8, kilobytes = bytes / K, megabytes = kilobytes / K, gigabytes = megabytes / K, terabytes = gigabytes / K;
var bytes = V, kilobytes = bytes / K, megabytes = kilobytes / K, gigabytes = megabytes / K, terabytes = gigabytes / K;
if(terabytes >= K) {return put(terabytes / K, 'PiB')}
if(gigabytes >= K) {return put(terabytes, 'TiB')}
if(megabytes >= K) {return put(gigabytes, 'GiB')}
Expand Down

0 comments on commit c9019c7

Please sign in to comment.