(Get this in the correct thread:)

-------- Original Message --------
Subject: [Jprogramming] [Fwd: Re:  boxes]
Date: Mon, 05 Apr 2010 17:24:24 -0500
From: Kip Murray <[email protected]>
Reply-To: Programming forum <[email protected]>
To: Programming forum <[email protected]>

Raul, I will look over your proposed solutions; here I attempt to deal with your
questions about what I meant.  --Kip


            (z)
             2
             |
             |
             +------+ 0 1 1
            /      /|
           /      / |
          +------+  +------1(y)
          |      | /
          |      |/
          +------+ 1 1 0
         /
        /
       0
      (x)


Above is my attempt to draw the unit cube in the "first octant" of an xyz
coordinate system.  In J we speak of the 0-axis, 1-axis, and 2-axis as opposed
to x-axis, y-axis and z-axis, but I will use the more familiar xyz terminology 
now.

You are supposed to be seeing a cube in a corner of a room.  The floor is part
of the xy plane, the left wall is part of the xz plane, the back wall is part of
the yz plane.

The point with coordinates 1 1 0 (1 in the x direction, 1 in the y direction, 0
in the z direction) is on the floor, the point with coordinates 0 1 1 is on the
back wall, and the point 1 1 1 (not labeled in the drawing) is 1 unit from each
of the walls.  It is the "front upper right" corner of the cube.

Remember that located vector a ,; h runs from location a (the tail) to location
a+h (the head).

Located vector 0 0 0 ,: 1 1 1 runs from the origin to the point 1 1 1 and
represents this cube.  It is the "canonical representation" of the cube.
Located vector 1 1 1 ,: _1 _1 _1 runs from the point 1 1 1 to the origin and is
another representation of this cube.

Located vector 0 0 1 ,: 1 1 0 runs from the rear left corner of the top face of
the cube to the front right corner of the top face; it is the canonical
representation of the top face.  Located vector 1 1 1 ,: _1 _1 0 runs from the
front right corner of the top face to the rear left corner and is another
representation of the top face.

Thus cr 1 1 1 ,: _1 _1 _1 is 0 0 0 ,: 1 1 1 ,
and cr 1 1 1 ,: _1 _1 0 is 0 0 1 ,: 1 1 0 .


In the closing lines of my 4 April "boxes" post I tried to say what I wanted:

"DO YOU REMEMBER YOUR ASSIGNMENT?  Write a verb that finds the faces of a box.
That is, given a located vector representing the box, find located vectors
representing the faces."


-------- Original Message --------
Subject: Re: [Jprogramming] boxes
Date: Mon, 5 Apr 2010 13:08:36 -0400
From: Raul Miller <[email protected]>
Reply-To: Programming forum <[email protected]>
To: Programming forum <[email protected]>
References: <[email protected]>
<[email protected]> <[email protected]>
<[email protected]> <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>

Ok, Kip wanted faces, not face points...

But what does that mean?

In some examples, he was using vectors running
from the center of the cube to the corners, but
his question was about cubes not described that
way.  His question was about cubes described by
vectors running from one corner of the cube to its
diagonal opposite.

I am still trying to puzzle out what he meant by his
example data for faces -- if faces are represented by
located vectors for the faces, and the cube had corners
with coordinates _1 and 1 then all faces should be
described by located vectors with coordinates _1 and 1.

But that is not how his example data looks -- it has
zeros in it.

This leaves us with a problem of ambiguous notation.
But presumably, in the absence of any test data,
any solution which satisfies the verbal description
should be adequate.  Thus, I think this qualifies
as a complete solution:

facepoints=: ,/@~.@:| * _1 ^ 2 #:@i...@^ #
F=: {. (] +"1 facepoints@:-) +/ %#
face=: ] ,:"1 [ #~ 1 = ] +/@:="1 [
faces=: ((face {.), (face {:))@F


Example use:
     faces 1,:3#_1

-- 
Raul
----------------------------------------------------------------------
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

Reply via email to