In the turtle graphics system I am developing, I
force the angular headings of objects expressed in degrees
to the range (_180,180] with the verb dfd shown below. So
for example dfd produces the following results for an object
with a starting heading of 0 degrees and turning 45 degrees
to the right at each step until it completes a 360 turn.
dfd=: 360&|&.(180&-)
(,: dfd)45*i. 9
0 45 90 135 180 225 270 315 360
0 45 90 135 180 _135 _90 _45 0
The following two boxes show the behavior of a >:
comparison table for angles between 0 and 360 degrees
without and with the dfd translation. I think I understand
how I could programatically stop a turning object at a
desired heading in the table of raw angle comparisons (using
the simple >: primitive), but not how to do so for the
righthand table of dfd'd angle comparisons. How can I do the
latter? I suppose I am asking what is the inverse of dfd.
(>:/;>:/&dfd)~45*i. 9
+-----------------+-----------------+
|1 0 0 0 0 0 0 0 0|1 0 0 0 0 1 1 1 1|
|1 1 0 0 0 0 0 0 0|1 1 0 0 0 1 1 1 1|
|1 1 1 0 0 0 0 0 0|1 1 1 0 0 1 1 1 1|
|1 1 1 1 0 0 0 0 0|1 1 1 1 0 1 1 1 1|
|1 1 1 1 1 0 0 0 0|1 1 1 1 1 1 1 1 1|
|1 1 1 1 1 1 0 0 0|0 0 0 0 0 1 0 0 0|
|1 1 1 1 1 1 1 0 0|0 0 0 0 0 1 1 0 0|
|1 1 1 1 1 1 1 1 0|0 0 0 0 0 1 1 1 0|
|1 1 1 1 1 1 1 1 1|1 0 0 0 0 1 1 1 1|
+-----------------+-----------------+
--
(B=)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm