[Jprogramming] cubes
Kip Murray
km at math.uh.edu
Sun Apr 4 10:18:42 HKT 2010
Note, the table a ,: h where a and h are vectors can be thought of as a "located
vector": a is the location of the tail, h contains the components and thus
specifies the length and direction. I regard the located vector a ,: h as a
diagonal through the center of a box whose edges are parallel to the coordinate
axes. The box is completely determined by this description, and in special
cases can be a face or an edge. --Kip Murray
Kip Murray wrote:
> NB. The "box" in direction h from base-point a is the array a ,: h
> NB. Vectors a and a+h are diagonally opposite corners of this "box".
> NB.
> NB. Items of the following array are the eight unit cubes based at 0 0 0
>
> ]cubes =: 8 2 3 $ cubedata
> 0 0 0
> _1 _1 _1
>
> 0 0 0
> _1 _1 1
>
> 0 0 0
> _1 1 _1
>
> 0 0 0
> _1 1 1
>
> 0 0 0
> 1 _1 _1
>
> 0 0 0
> 1 _1 1
>
> 0 0 0
> 1 1 _1
>
> 0 0 0
> 1 1 1
>
> NB. Items of the following array are the six faces of cube 0 0 0 ,: 1 1 1
>
> ]faces =: 6 2 3 $ facedata
> 0 0 0
> 0 1 1
>
> 0 0 0
> 1 0 1
>
> 0 0 0
> 1 1 0
>
> 1 1 1
> _1 _1 0
>
> 1 1 1
> _1 0 _1
>
> 1 1 1
> 0 _1 _1
>
> NB. Exercise for the reader: write verbs to produce cubes and faces.
>
> --Kip Murray
>
>
> Kip Murray wrote:
>> Consider a ,: b where a is a vertex and a+b is the diagonally opposite
>> vertex. An equivalent "cube" with vertex at the origin n would be n ,:
>> b . Think about it. Kip
>>
>>
>> Raul Miller wrote:
>>> 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,
>>>
>> ------------------------------------------------------------------------
>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list