We locate the centroid of a slice with this code. The argument to c is a vector v all of whose components must be positive. If v is a vector then c(v) returns moments 0 and 1 of {x|x∙v<1}∩[0, 1]n. The centroid may be computed as (moment 1)/(moment 0). This yields the coordinates of the centroid in the system of the preferred cube corner. bt is the moments of the ‘big tent’.
If σx is a permutation of the components of x and c(x) = (c, m) then c(σx) = (c, σm).
There is a floating point error in c proportional to 1/(product of components of argument).
c fails if any component of its argument is 0 but
lim(x→0)c OF c((x, y, … w, x)) = c OF c((x, y, … w)) and
lim(x→0)m OF c((x, y, … w, x)) = m OF c((x, y, … w)) with a c/2 appended to the vector.
Of the arguments to c we say that x and y are complementary if 1/Σxi + 1/Σyi = 1. The cube slices produced by complementary arguments form complements to the cube if you reflect one of them about the center of the cube. If x is an argument to c then ip(x) is the complementary argument.
From this equation:
m'j
= ∫ (xj + dj)dm
= mj + mdj
from here we conclude that the vector sum of the moment 1’s should be (½, ½, …).
Consider the test ts((3, 0.001)) and corresponding test.
That divides the square very nearly into .
centroid 1 m1/m0 centroid 2 (1, 1, …) - m1'/m0' Weighted mean at (½, ½, …) (m1/m0)m0 + ((1, 1, …) - m1'/m0')m0' = (½, ½, …) m1 + (m0', m0', …) - m1'mq is the location of the centroid of combined slices a and b when b is reflected thru the cube center. I take it as good evidence that the routine c is correct that “Foul cent” is not printed.
sl is the fraction of the vertical body diagonal above the water.
Code constructs beginning “(0=1 |” are code fragments that are turned off. Changing them to begin “(0=0 |” turns them on. Each is a test of sorts.
The three columns are: