Essays/Clockwise Angles

From J Wiki
Jump to: navigation, search

Angle B is clockwise to angle A (A cw B) if the counter-clockwise arc which spans from A to B is reflex (greater than 180 degrees).

Clockwise relation is independent of angle representation and invariant to shift of angles around the circle.

Clockwise.png

Rows have the same angle A and spanning angle B across columns. The uncolored angle in each graphic position quantifies the clockwise angle.

Blue is  1 = A cw B
Red is _1 = A cw B
Gray is  0 = A cw B

Note: the diagonals parallel to main (i-j = const) represent arcs of the same size.

The following script generates the illustration above. Download script:

require 'gl2 trig ~system/examples/phrases/phrc7.ijs'
coinsert 'jgl2'

vec2=: +.@r.
cw=: *@cross1&vec2"0

F=: 0 : 0
pc f;pn "Clockwise Angles";
xywh 6 6 200 200;cc g isigraph rightmove bottommove;
pas 6 6;pcenter;
rem form end;
)

f_run=: 3 : 0
  wd F
  wd 'pshow;'
)

f_close=: 3 : 0
  wd'pclose'
)

arc=: 4 : 0
  'X Y R'=. x
  'A Z'=. y
  x0=. X-R [ y0=. Y-R
  xa=. X+R*cos A [ ya=.Y-R*sin A [ xz=.X+R*cos Z [ yz=.Y-R*sin Z
  glpie x0,y0,(2*R),(2*R),xa,ya,xz,yz
  gllines xa,ya,X,Y,xz,yz
)

f_g_paint=: 3 : 0
  glclear''
  for_i. i.20 do.
    for_j. i.20 do.
      select. cw/ az=. 1r4p1*i,j
        case.  1 do.
  glpen 1 0 [ glrgb 180 90 90
  glbrush [ glrgb 255 160 160
        case. _1 do.
  glpen 1 0 [ glrgb 100 100 160
  glbrush [ glrgb 160 160 255
        case.    do.
  glpen 1 0 [ glrgb 120 120 120
  glbrush [ glrgb 200 200 200
      end.
      ((10+20*j,i),9) arc az
    end.
  end.
  glpaint''
)

f_run''


Contributed by Oleg Kobchenko