On Mon, Jan 26, 2009 at 3:13 PM, Jean-François Bigot
<[email protected]> wrote:
> Hi Ed
> I looked rapidly to your code, there are lot of interesting things.
> 1. locals
> :: do-camera-look-at ( CAMERA -- )
>    [let | EYE   [ CAMERA pos>> ]
>           FOCUS [ CAMERA clone 1 step-turtle pos>> ]
>
>  UP    [ CAMERA clone 90 pitch-up 1 step-turtle pos>> CAMERA pos>> v- ]
>         |
>      EYE FOCUS UP gl-look-at ] ;
> can be compared to old "camera" vocab
> : camera-eye ( -- point ) turtle-pos> ;
> : camera-focus ( -- point ) [ 1 step-turtle turtle-pos> ] save-self ;
> : camera-up ( -- dirvec )
> [ 90 pitch-up turtle-pos> 1 step-turtle turtle-pos> swap v- ] save-self ;
> : do-look-at ( camera -- )
> [ >self camera-eye camera-focus camera-up gl-look-at ] with-scope ;
>
> I must admit that "self" vocab is very un-intuitive, in that case [let seems
> to be a good choice.

Here is a version using combinators:

: do-camera-look-at ( camera -- )
    [ pos>> ]
    [ clone 1 step-turtle pos>> ]
    [ [ clone 90 pitch-up 1 step-turtle pos>> ] [ clone pos>> ] bi v- ] tri
    gl-look-at ;

Slava

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to