Re: The Euphoria Sub Commander project

new topic     » goto parent     » topic index » view thread      » older message » newer message

Pete Lomax wrote:
> 
> don cole wrote:
> > 
> > 
> > Could someone please explain the following code to me in detail? I'm
> > especially
> > confused by the
> > {} brackets.
> > 
> > }}}
<eucode>
> > 
> > k=player --1 or 2
> > cen={{120,360},{520,360}},     -- centers of clock
> Two clocks, center of 1 is {120,360} and the centre of 2 is {520,360}
> 
> > r=100,     -- radius of clock
> > rt=remaining time in secs
> > 
> > 
> > Don Cole
> >  
> > function p2xy(atom r, atom a)   -- polar to xy
> >    return {-r*sin(a),-r*cos(a)}
> > end function
> > 
> > draw_line(colors[k],{cen[k],cen[k]+p2xy(r,rt/1800*PI)})
> 
> Draws a line from the centre of the clock to somewhere on the edge.
> 
> As sin/cos expect arguments in radians, 0..2*PI, and rt is 0..3600, the number
> of seconds in an hour, it is coded as /1800*PI rather than /3600*2*PI.
> 
> Now imagine a clock with the second hand pointing at 10 seconds past the hour,
> drop a line to
> the horizontal through the centre to make a right angled triange whose longest
> side is the second
> hand. For a picture, see eg <a
> href="http://www.mathsrevision.net/gcse/pages.php?page=39">http://www.mathsrevision.net/gcse/pages.php?page=39</a>
> 
>  From basic trig, the height of this triangle is r*sin(a) and the width is
>  r*cos(a).
> (I almost always get such the wrong way round on first attempt.) 
> 
> Lastly, rt is the remaining time, a hand pointing at 2 o'clock would be
> (10/12)*3600
> or 3000 seconds which should explain why the offsets from the clock centre to
> the tip of the arm are both returned as -ve.
> 
> Hope that is enough detail for you there,
> Pete

  I want to thank everyone who responded.

I kind of figured it out after I went to bed last night. It was the adding to
cen[k] that confused me. cen[k] is a two element sequence the starting point of
the line. The return of p2xy() is also a two element sequence. I guess you can
add sequences together if they are the same length. This gives a third sequence
which is where to put the end of the line.


Don Cole

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu