This is very nice. Thank you, R.E. Boss.
R.E. Boss wrote:
...
> Reason I prefer to explain kfcs is I like the shape of the output.
> I made up the explanation after I constructed the solution.
>
>
> Suppose C=: 10 20 30 40 ,: 1 2 3 4 is the origin (or original vertex) and
> the diagonal (vector) of a 4D cube.
> Question is how to generate, say, the 2-faces of that cube.
> Let the coordinates be (x,y,z,w).
>
> It is obvious that the diagonal of a face (of the cube) is the projection of
> the (main) diagonal.
> So on a plane (z,w) = constant the diagonal is 1 2 0 0.
> The values these constant can take are one of (z,w) = 30 40, 30 44, 33 40
> and 33 44.
> So these 2-faces can be represented by
>
> 10 20 30 40
> 1 2 0 0
>
> 10 20 30 44
> 1 2 0 0
>
> 10 20 33 40
> 1 2 0 0
>
> 10 20 33 44
> 1 2 0 0
>
> So the general rule which can be derived from this is:
> A. make the projections of the diagonal on all 2-faces
> B. determine the origins of all 2-faces with such a projected diagonal.
>
> A.
> For a 2-face, we need 2 non-zeroes so first generate these:
>
> [d1=:({:C) *"1 (#~ 2 = +/"1 ) t=. #:i.2^{:$ C
> 0 0 3 4
> 0 2 0 4
> 0 2 3 0
> 1 0 0 4
> 1 0 3 0
> 1 2 0 0
>
> These are all the diagonals in the 2-faces.
>
> B.
> For each diagonal we get the origins by adding to {.C zero or more of the
> coordinates of the diagonal which have become 0 in the projection:
>
> {: r1=: ({.C) +"1 ({:C) *"1 t ([ #~ 0 = [ +/@:*"(1) 0~:])"_ 1 d1
> 10 20 30 40
> 10 20 30 44
> 10 20 33 40
> 10 20 33 44
>
> A. and B. together give the required result:
>
> {: r1 ,:"1"_1 d1
> 10 20 30 40
> 1 2 0 0
>
> 10 20 30 44
> 1 2 0 0
>
> 10 20 33 40
> 1 2 0 0
>
> 10 20 33 44
> 1 2 0 0
>
> Bringing this all together and smoothing things up a bit gives
>
> kfcs=: 3 : 0
> (i.>:{:$y) <@kfcs"0 _ y
> :
> t1=. (#~ x = +/"1 ) t=. #:i.2 ^ {:$y
> t2=. ({.y) +"1 ({:y) *"1 t1 (] #~ 0 = +/@:*"1)"1 _ t
> t2 ,:"1"_1 ({:y) *"1 t1
> )
>
> which differs slightly from the original kfcs.
>
>
> R.E. Boss
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm