Hello, R.E. Boss,
It will probably be Tuesday or Wednesday before I can attempt to understqand
how
your verb kfcs works. In the meantime, are you willing to give an explanation
analogous to my explanation below of verb cr?
Here is how monadic verb cr (canonical representation) 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 "lower left rear corner" llr . Then llr ,: |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 corner or an edge or a face or a "whole box."
Kip
R.E. Boss wrote:
> <"2 ] 3 kfaces C
> |length error: kfaces
> | ,/(({.y)+"1({:y)*"1 (#^:_1"1#:@i.@(2^+/))"1 id),:"1({:y)*"1-.id
>
> 3-face of the cube should be included as well.
>
>
> A simpler alternative:
>
> kfcs=: 3 : 0
> t1=. t=. #:i.2^{:$y
> ;(<y) (*"1&{: ,:~"1 {...@] +"1 }:@[ *"1 {:@] )~&.> t1 <@([ ,~ ] #~ 0 =
> +/@:*"1)"1 _ t
> :
> t1=. (#~ x = +/"1 ) t=. #:i.2^{:$y
> y (*"1&{: ,:~"1 {...@] +"1 }:@[ *"1 {:@] )~"2 t1 ([ ,~ ] #~ 0 = +/@:*"1)"1 _
> t
> )
>
> <"2 ] 0 kfcs 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 kfcs C
> +------+-------+------+-------+
> |4 3 0|4 0 0 |0 3 0|0 0 0 |
> |0 0 _2|0 0 _2 |0 0 _2|0 0 _2 |
> +------+-------+------+-------+
> |4 3 0|4 3 _2|0 3 0|0 3 _2|
> |0 _3 0|0 _3 0|0 _3 0|0 _3 0|
> +------+-------+------+-------+
> | 4 3 0| 4 3 _2| 4 0 0| 4 0 _2|
> |_4 0 0|_4 0 0|_4 0 0|_4 0 0|
> +------+-------+------+-------+
>
> <"2 ] 2 kfcs C
> +-------+--------+
> |4 3 0|0 3 0 |
> |0 _3 _2|0 _3 _2 |
> +-------+--------+
> | 4 3 0| 4 0 0 |
> |_4 0 _2|_4 0 _2 |
> +-------+--------+
> | 4 3 0| 4 3 _2|
> |_4 _3 0|_4 _3 0|
> +-------+--------+
>
> <"2 ] 3 kfcs C
> +--------+
> | 4 3 0|
> |_4 _3 _2|
> +--------+
>
> faces are ordered to their diagonal vector.
>
> Without left argument, all faces are given:
>
> $ kfcs C
> 27 2 3
>
>
> For higher dimensions:
>
> 2 (kfcs -:&(,@:(<"2)) kfaces) 4 3 0 _2,:_4 _3 _2 1
> 1
>
> $ kfcs 4 3 0 _2,:_4 _3 _2 1
> 81 2 4
>
>
> R.E. Boss
>
>
>> -----Oorspronkelijk bericht-----
>> Van: [email protected] [mailto:programming-
>> [email protected]] Namens Andrew Nikitin
>> Verzonden: vrijdag 9 april 2010 22:01
>> Aan: J programming
>> Onderwerp: Re: [Jprogramming] boxes
>>
>>
>>> From: Kip Murray
>>>
>>> Andrew, Oleg's dyadic verb faces below works correctly on my example
>>> 4 3 0 ,: _4 _3 _2 -- try
>>>
>>> <"_1 [ 4 3 0 faces _4 _3 _2
>>>
>>> -- and Oleg claims his faces works in all dimensions, see his examples
>> below.
>> I 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
>> ------T------T-----T------T-----T------T-----T------┐
>> │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│
>> L-----+------+-----+------+-----+------+-----+-------
>> <"2 ] 1 kfaces C
>> -------T------T------T------T------T-------T------T-------T------T-------T
>> ------T-------┐
>> │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│
>> L------+------+------+------+------+-------+------+-------+------+-------+
>> ------+--------
>> <"2 ] 2 kfaces C
>> --------T-------T-------T-------T-------T--------┐
>> │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│
>> L-------+-------+-------+-------+-------+---------
>>
>> _________________________________________________________________
>> Hotmail has tools for the New Busy. Search, chat and e-mail from your
>> inbox.
>> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON
>> :WL:en-US:WM_HMP:042010_1
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm