I am looking for elegant ways of describing cubes in J.

For example:

points=: _1+2*#:i.8
surfaces=: 1 A. I. (, 1 - |.) 8&$...@#&0 1">4 2 1

Here, points is a list of vertices and a vertex is
a list of xyz coordinates, and surfaces is a list
of polygons where a polygon is a list of
four vertex indices.

Here, I consider 'points' to be elegant, but I am
looking for something more meaningful (and yet
still concise) for surfaces.

Here is an example of an equivalent but more meaningful
expression for surfaces:

surfaces=:  1 A."1 I. (#~ (1 e. [: */^:2 0: = points -"1/~...@#~ ])"1)
(#~ 4=+/"1)#:i.2^#points

Here, I start by generating every combination of the available
points, choosing those combinations which have four
points, then choosing those combinations which are coplanar
and then rearranging them.  This is somewhat meaningful
(though that 1 A. bothers me), but it is not concise.

Does anyone have any good ideas for a meaningful
sentence to define 'surfaces'?

Thanks,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to