<commit_before>USING: kernel namespaces math math.constants math.functions arrays sequences
    opengl opengl.gl opengl.glu ui ui.render ui.gadgets ui.gadgets.theme
    ui.gadgets.slate colors ;
IN: golden-section

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! To run:
! "golden-section" run

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: disk ( quadric radius center -- )
    glPushMatrix
    gl-translate
    dup 0 glScalef
    0 1 10 10 gluDisk
    glPopMatrix ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: omega ( i -- omega ) phi 1- * 2 * pi * ;

: x ( i -- x ) dup omega cos * 0.5 * ;

: y ( i -- y ) dup omega sin * 0.5 * ;

: center ( i -- point ) dup x swap y 2array ;

: radius ( i -- radius ) pi * 720 / sin 10 * ;

: color ( i -- color ) 360.0 / dup 0.25 1 4array ;

: rim ( quadric i -- )
    black gl-color dup radius 1.5 * swap center disk ;

: inner ( quadric i -- )
    dup color gl-color dup radius swap center disk ;

: dot ( quadric i -- ) 2dup rim inner ;

: golden-section ( quadric -- ) 720 [ dot ] with each ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: with-quadric ( quot -- )
    gluNewQuadric [ swap call ] keep gluDeleteQuadric ; inline

: display ( -- )
    GL_PROJECTION glMatrixMode
    glLoadIdentity
    -400 400 -400 400 -1 1 glOrtho
    GL_MODELVIEW glMatrixMode
    glLoadIdentity
    [ golden-section ] with-quadric ;

: golden-section-window ( -- )
    [
        [ display ] <slate>
        { 600 600 } over set-slate-pdim
        "Golden Section" open-window
    ] with-ui ;

MAIN: golden-section-window<commit_msg>golden-section: revisit a few items<commit_after>
USING: kernel namespaces math math.constants math.functions arrays sequences
       opengl opengl.gl opengl.glu ui ui.render ui.gadgets ui.gadgets.theme
       ui.gadgets.slate colors accessors combinators.cleave ;

IN: golden-section

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: disk ( radius center -- )
  glPushMatrix
  gl-translate
  dup 0 glScalef
  gluNewQuadric [ 0 1 20 20 gluDisk ] [ gluDeleteQuadric ] bi
  glPopMatrix ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! omega(i) = 2*pi*i*(phi-1)

! x(i) = 0.5*i*cos(omega(i))
! y(i) = 0.5*i*sin(omega(i))

! radius(i) = 10*sin((pi*i)/720)

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: omega ( i -- omega ) phi 1- * 2 * pi * ;

: x ( i -- x ) [ omega cos ] [ 0.5 * ] bi * ;
: y ( i -- y ) [ omega sin ] [ 0.5 * ] bi * ;

: center ( i -- point ) { x y } 1arr ;

: radius ( i -- radius ) pi * 720 / sin 10 * ;

: color ( i -- color ) 360.0 / dup 0.25 1 4array ;

: rim   ( i -- ) [ drop black gl-color ] [ radius 1.5 * ] [ center ] tri disk ;
: inner ( i -- ) [      color gl-color ] [ radius       ] [ center ] tri disk ;

: dot ( i -- ) [ rim ] [ inner ] bi ;

: golden-section ( -- ) 720 [ dot ] each ;

! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

: display ( -- )
  GL_PROJECTION glMatrixMode
  glLoadIdentity
  -400 400 -400 400 -1 1 glOrtho
  GL_MODELVIEW glMatrixMode
  glLoadIdentity
  golden-section ;

: golden-section-window ( -- )
    [
      [ display ] <slate>
        { 600 600 } >>pdim
      "Golden Section" open-window
    ]
  with-ui ;

MAIN: golden-section-window
{'fraction_non_alphanumeric': 0.27889150943396224, 'fraction_numerical': 0.0347877358490566, 'mean_word_length': 2.8469387755102042, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5888895', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1134, 'n_words': 299}