Andrew, this looks very nice, thank you. I will now try to understand it.
Would you, Raul, and Oleg be willing to describe what your own "faces" programs
are doing -- how they accomplish their results?
I won't "peek" until I have tried to figure them out myself.
Here is how my monadic cr (canonical representation) verb works:
cr =: ({. + 0.5 * [: (- |) {:) ,: [: | {:
Given the argument a ,: h i.e. location ,: components of a box diagonal
vector, verb cr returns
((a + 0.5 * h) - 0.5 * |h) ,: |h
that is, cr locates the center a + 0.5 * h of the box and subtracts 0.5 * |h to
locate the "left rear corner" lr . Then lr ,: |h is the canonical
representation whose components are non-negative. I believe this approach
works
correctly in any number of dimensions and on any box, for example, in three
dimensions the "box" can be a an edge or a face or a "whole box."
Kip
Andrew Nikitin wrote:
...
> Olegs verb returns (n-1) dimensional faces of n-dimensional boxes.
> I meant k dimensional faces of n-dimensional boxes.
> For regular cube 2-face is what normally called "face", 1-face is an edge and
> 0-face is a vertex.
>
> require 'statfns'
> kfaces=:4 : 0"0 2
> n=.{:$y
> k=.x
> id=.(i.n) (e."1) (n-k) comb n
> ,/(({.y) +"1 ({:y) *"1 (#^:_1"1 #:@i.@(2 ^ +/))"1 id) ,:"1 ({:y) *"1 -.id
> )
>
> C=.4 3 0 ,: _4 _3 _2
> <"2 ] 0 kfaces C
> ┌─────┬──────┬─────┬──────┬─────┬──────┬─────┬──────┐
> │4 3 0│4 3 _2│4 0 0│4 0 _2│0 3 0│0 3 _2│0 0 0│0 0 _2│
> │0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│0 0 0│
> └─────┴──────┴─────┴──────┴─────┴──────┴─────┴──────┘
> <"2 ] 1 kfaces C
> ┌──────┬──────┬──────┬──────┬──────┬───────┬──────┬───────┬──────┬───────┬──────┬───────┐
> │4 3 0│4 0 0│0 3 0│0 0 0│4 3 0│4 3 _2│0 3 0│0 3 _2│ 4 3 0│ 4 3 _2│ 4
> 0 0│ 4 0 _2│
> │0 0 _2│0 0 _2│0 0 _2│0 0 _2│0 _3 0│0 _3 0│0 _3 0│0 _3 0│_4 0 0│_4 0 0│_4
> 0 0│_4 0 0│
> └──────┴──────┴──────┴──────┴──────┴───────┴──────┴───────┴──────┴───────┴──────┴───────┘
> <"2 ] 2 kfaces C
> ┌───────┬───────┬───────┬───────┬───────┬────────┐
> │4 3 0│0 3 0│ 4 3 0│ 4 0 0│ 4 3 0│ 4 3 _2│
> │0 _3 _2│0 _3 _2│_4 0 _2│_4 0 _2│_4 _3 0│_4 _3 0│
> └───────┴───────┴───────┴───────┴───────┴────────┘
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm