From: Frank Buss
Subject: Functional Geometry for fishes
Date: 
Message-ID: <ct0po8$57m$1@newsreader2.netcologne.de>
I never really understood how to use higher order functions as combinators, 
until I read the article from Peter Henderson about Functional Geometry. 
Now it is easy for me to use it in Lisp:

http://www.frank-buss.de/lisp/functional.html
http://www.frank-buss.de/lisp/fishes.pdf

-- 
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de

From: Rainer Joswig
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <joswig-E22A7E.20181423012005@news-50.dca.giganews.com>
In article <············@newsreader2.netcologne.de>,
 Frank Buss <··@frank-buss.de> wrote:

> I never really understood how to use higher order functions as combinators, 
> until I read the article from Peter Henderson about Functional Geometry. 
> Now it is easy for me to use it in Lisp:
> 
> http://www.frank-buss.de/lisp/functional.html
> http://www.frank-buss.de/lisp/fishes.pdf

Nice.

See also AIM-986.pdf or the corresponding article of Byte 1988, February.

ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-986.pdf

and

Hal Abelson and Gerald Jay Sussman. "Lisp: A Language for Stratified Design". BYTE. February 1988.
From: Emre Sevinc
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <87fz0ropei.fsf@ileriseviye.org>
Frank Buss <··@frank-buss.de> writes:

> I never really understood how to use higher order functions as combinators, 
> until I read the article from Peter Henderson about Functional Geometry. 
> Now it is easy for me to use it in Lisp:
>
> http://www.frank-buss.de/lisp/functional.html
> http://www.frank-buss.de/lisp/fishes.pdf
>

As Rainer Joswig pointed out, Scheme designers were interested
with Henderson's examples, too.

For people who want to see Henderson's ideas in action
this video set is a good choice. I guess it is the 4th or 5th
.avi file that includes a lecture about how to produce
Escher style pictures using a functional programming
language and Henderson's ideas:

 http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/

Now that we have Common Lisp version which produces
Postscript output, we're one step closer to total world
domination! ;-)




-- 
Emre Sevinc

eMBA Software Developer         Actively engaged in:
http:www.bilgi.edu.tr           http://ileriseviye.org
http://www.bilgi.edu.tr         http://fazlamesai.net
Cognitive Science Student       http://cazci.com
http://www.cogsci.boun.edu.tr
From: Marc Battyani
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <ct13tb$op8@library2.airnews.net>
"Emre Sevinc" <·····@bilgi.edu.tr> wrote

> For people who want to see Henderson's ideas in action
> this video set is a good choice. I guess it is the 4th or 5th
> .avi file that includes a lecture about how to produce
> Escher style pictures using a functional programming
> language and Henderson's ideas:
>
>  http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/
>
> Now that we have Common Lisp version which produces
> Postscript output, we're one step closer to total world
> domination! ;-)

Postscript is deprecated. Today, world domination requires that you produce
PDF output with cl-pdf ;-)

Marc
From: Rainer Joswig
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <joswig-3C2A11.22333923012005@news-50.dca.giganews.com>
In article <··········@library2.airnews.net>,
 "Marc Battyani" <·············@fractalconcept.com> wrote:

> "Emre Sevinc" <·····@bilgi.edu.tr> wrote
> 
> > For people who want to see Henderson's ideas in action
> > this video set is a good choice. I guess it is the 4th or 5th
> > .avi file that includes a lecture about how to produce
> > Escher style pictures using a functional programming
> > language and Henderson's ideas:
> >
> >  http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/
> >
> > Now that we have Common Lisp version which produces
> > Postscript output, we're one step closer to total world
> > domination! ;-)
> 
> Postscript is deprecated. Today, world domination requires that you produce
> PDF output with cl-pdf ;-)
> 
> Marc

Actually if you use CLIM, you can directly generate
Postscript from its graphics routines.

See:

http://www.lispworks.com/documentation/lw44/CLIM/html/climguide-341.htm#pgfId-44383

What would be neat is to generate PDF like that (perhaps with cl-pdf)
from McCLIM (http://common-lisp.net/project/mcclim/).
From: Marc Battyani
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <ct16en$5em@library2.airnews.net>
"Rainer Joswig" <······@lisp.de> wrote
>  "Marc Battyani" <·············@fractalconcept.com> wrote:

> > Postscript is deprecated. Today, world domination requires that you
produce
> > PDF output with cl-pdf ;-)
>
> Actually if you use CLIM, you can directly generate
> Postscript from its graphics routines.
>
> See:
>
>
http://www.lispworks.com/documentation/lw44/CLIM/html/climguide-341.htm#pgfI
d-44383
>
> What would be neat is to generate PDF like that (perhaps with cl-pdf)
> from McCLIM (http://common-lisp.net/project/mcclim/).

Well it should be easy, Postscript and PDF share the same graphic model.

Marc
From: Trent Buck
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <20050124141423.4b068df4@harpo.marx>
Up spake Emre Sevinc:
> For people who want to see Henderson's ideas in action
> this video set is a good choice.

http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/Lecture-3a.avi

...about halfway through that video.

-- 
-trent
I'm not sure if this is a good or a bad thing.  Probably a bad thing;
most things are bad things. -- Nile Evil Bastard
From: Frank Buss
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <ct1ti5$48h$1@newsreader2.netcologne.de>
Trent Buck <·········@tznvy.pbz> wrote:

> Up spake Emre Sevinc:
>> For people who want to see Henderson's ideas in action
>> this video set is a good choice.
> 
> http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/Lectu
> re-3a.avi 
> 
> ...about halfway through that video.

Interesting lecture. The base concept is slightly different: My 
"picture" returns a list of lines when called, while his picture draws 
itself when called, but the rest is the same. But I don't like the Scheme 
notation, because for me it is more clear to see a "funcall" when a 
function is being called.

Another good part: at the end of the lecture he compares the top-down 
methodology with the "levels of languages" methodology and explains why 
it is more robust to use embedded languages in Lisp.

Regarding the picture: Would be nice to enhance the program to produce a 
more exact reproduction of the original picture, filled with color, with 
curved lines and recursive to level n (see "Square Limit"):

http://www.dartmouth.edu/~matc/math5.pattern/lesson7math.html

-- 
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: GP lisper
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <1106576653.d99305b82a9725848d1fded3b202ba9a@teranews>
On Mon, 24 Jan 2005 04:28:53 +0000 (UTC), <··@frank-buss.de> wrote:
>
> Regarding the picture: Would be nice to enhance the program to produce a 
> more exact reproduction of the original picture, filled with color, with 
> curved lines and recursive to level n (see "Square Limit"):

Well, if you examine the Escher picture, you can see at least 2
different 'fish'.  Henderson claimed that there are 4, but I couldn't
find 2 more.  In the second paper, Henderson describes a 'triangle
effect' (the second fish is the first fish with this triangle merged
into one wing), which alas, is also visible in your graphics (p,q,r,s
are incomplete apparently).  Adding color will only enhance the
triangles.  Escher covered them up rather well by two-tone shading and
partial line segments to trick your eye.

The second papers discussion of there actually being a single curved
line segment that generates the outline of the fish is the more
interesting piece (IMO).  That curve is drawn about a right triangle,
with some simple operations occurring, but the key rot45 appears on
the hypotenuse.  Following up this concept with a line generator which
is then mapped onto the right triangle for the tessellations, in
common lisp with .ps (or .pdf) output would be neat.

Thanks for providing some interesting reading and thinking Frank!

-- 
Everyman has three hearts;
one to show the world, one to show friends, and one only he knows.
From: Geoffrey Summerhayes
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <cR0Kd.8133$mA5.554184@news20.bellglobal.com>
"GP lisper" <········@CloudDancer.com> wrote in message ················································@teranews...
> On Mon, 24 Jan 2005 04:28:53 +0000 (UTC), <··@frank-buss.de> wrote:
>>
>> Regarding the picture: Would be nice to enhance the program to produce a
>> more exact reproduction of the original picture, filled with color, with
>> curved lines and recursive to level n (see "Square Limit"):
>
> Well, if you examine the Escher picture, you can see at least 2
> different 'fish'.  Henderson claimed that there are 4, but I couldn't
> find 2 more.  In the second paper, Henderson describes a 'triangle
> effect' (the second fish is the first fish with this triangle merged
> into one wing), which alas, is also visible in your graphics (p,q,r,s
> are incomplete apparently).  Adding color will only enhance the
> triangles.  Escher covered them up rather well by two-tone shading and
> partial line segments to trick your eye.

Well, curve support looks easy to add, just use
((x1 y1)(x2 y2)(x3 y3)(x4 y4))
to define a bezier curve, change the loop in GRID to:

(loop for line in s collect
      (mapcar (lambda (point)
                (p+ (p/ (p* b (first point)) m) a (p/ (p* c (second point)) n)))
              line))

and alter PLOT:

(ecase (length line)
    (2  (... "~D ~D moveto ~D ~D lineto~%" ...))
    (4  (... "~D ~D moveto ~D ~D ~D ~D ~D ~D curveto~%" ...)))

That should do it. (untested)

--
Geoff 
From: Frank Buss
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <cu1nr8$eam$2@newsreader2.netcologne.de>
GP lisper <········@CloudDancer.com> wrote:

> Well, if you examine the Escher picture, you can see at least 2
> different 'fish'.  Henderson claimed that there are 4, but I couldn't
> find 2 more.

http://www.dartmouth.edu/~matc/math5.pattern/squarelimitp41.gif

take a look at the fins: there are two types of big fins and two types of 
small fins. The big red fishes in the center has another big fin than the 
red fish above the center. And the red fish top right the center has 
another small fin. The white fish top right this fish has the same small 
fin, but the same big fin as the big red fish. So you have all 4 
combinations.

-- 
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: GP lisper
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <1107685276.722b68d9d44a5afbbcc75ce18b3f5059@teranews>
On Sat, 5 Feb 2005 06:07:36 +0000 (UTC), <··@frank-buss.de> wrote:
> GP lisper <········@CloudDancer.com> wrote:
>
>> Well, if you examine the Escher picture, you can see at least 2
>> different 'fish'.  Henderson claimed that there are 4, but I couldn't
>> find 2 more.
>
> http://www.dartmouth.edu/~matc/math5.pattern/squarelimitp41.gif
>
> take a look at the fins: there are two types of big fins and two types of 
> small fins. The big red fishes in the center has another big fin than the 
> red fish above the center. And the red fish top right the center has 
> another small fin. The white fish top right this fish has the same small 
> fin, but the same big fin as the big red fish. So you have all 4 
> combinations.

Ok, I see the rounded small fins now.

Thanks again for a great puzzle and lisp Frank.  I certainly enjoy
your posts to c.l.l.



-- Everyman has three hearts; one to show the world, one to show
friends, and one only he knows.
From: Rainer Joswig
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <joswig-3B29C8.05421730012005@news-50.dca.giganews.com>
In article <············@newsreader2.netcologne.de>,
 Frank Buss <··@frank-buss.de> wrote:

> I never really understood how to use higher order functions as combinators, 
> until I read the article from Peter Henderson about Functional Geometry. 
> Now it is easy for me to use it in Lisp:
> 
> http://www.frank-buss.de/lisp/functional.html
> http://www.frank-buss.de/lisp/fishes.pdf

A picture of playing around with the code in LispWorks CLIM
on my iMac G5:

http://lispm.dyndns.org/lisp/pics/fg.jpg

Note that you can have commands to manipulate pictures
(via command line, menus or even drag&drop) and
that CLIM can generate postscript.

The code looks like this:

(define-presentation-type picture ())

(define-presentation-method presentation-typep (object (type picture))
  (typep object 'function))

;;; Plotting

(defun clim-plot (p  &optional (stream *standard-output*))
  (fresh-line stream)
  (with-output-as-presentation (stream p 'picture :single-box t)
    (with-room-for-graphics (stream)
      (with-scaling (stream 200 200)
        (with-translation (stream 0.1 0.1)
          (loop for (x0 y0 x1 y1) in '((0 0 1 0) (1 0 1 1) (1 1 0 1) (0 1 0 0))
                do (draw-line* stream x0 y0 x1 y1))
          (dolist (line (funcall p (make-point 0 0) (make-point 1 0) (make-point 0 1)))
            (destructuring-bind (p0 p1) line
              (draw-line stream p0 p1))))))))

(defun clim-plot-in-window (p &optional (stream *standard-output*))
  (clim-plot p stream))

(defun clim-plot-to-postscript (p &optional (pathname "/Users/joswig/Desktop/test-clim.ps"))
  (with-open-file (file-stream pathname
                               :direction :output
                               :if-exists :supersede
                               :if-does-not-exist :create)
   (with-output-to-postscript-stream (stream file-stream)
     (clim-plot p stream))))

(clim-demo::define-lisp-listener-command (clim-demo::save-picture-as-postscript :name t)
    ((picture 'picture :provide-default nil :prompt "picture")
     (file 'pathname :provide-default nil :prompt "file"))
  (clim-plot-to-postscript picture file)
  (values file picture))

(clim-demo::define-lisp-listener-command (clim-demo::com-beside :name t)
    ((picture0 'picture :provide-default nil :prompt "picture 0")
     (picture1 'picture :provide-default nil :prompt "picture 1"))
  (let ((new-picture (beside picture0 picture1)))
    (clim-plot new-picture)
    new-picture))

(clim-demo::define-lisp-listener-command (clim-demo::com-above :name t)
    ((picture0 'picture :provide-default nil :prompt "picture 0")
     (picture1 'picture :provide-default nil :prompt "picture 1"))
  (let ((new-picture (above picture0 picture1)))
    (clim-plot new-picture)
    new-picture))

(clim-demo::define-lisp-listener-command (clim-demo::com-rot :name t)
    ((picture 'picture :provide-default nil :prompt "picture"))
  (let ((new-picture (rot picture)))
    (clim-plot new-picture)
    new-picture))

(clim-demo::define-lisp-listener-command (clim-demo::com-cycle :name t)
    ((picture 'picture :provide-default nil :prompt "picture"))
  (let ((new-picture (cycle picture)))
    (clim-plot new-picture)
    new-picture))

(clim-demo::define-lisp-listener-command (clim-demo::com-quartet :name t)
    ((picture0 'picture :provide-default nil :prompt "picture 0")
     (picture1 'picture :provide-default nil :prompt "picture 1")
     (picture2 'picture :provide-default nil :prompt "picture 2")
     (picture3 'picture :provide-default nil :prompt "picture 3"))
  (let ((new-picture (quartet picture0 picture1 picture2 picture3)))
    (clim-plot new-picture)
    new-picture))

(define-presentation-to-command-translator rot
    (picture clim-demo::com-rot clim-demo::lisp-listener :menu t :gesture :menu)
    (object)
  (list object))

(define-presentation-to-command-translator cycle
    (picture clim-demo::com-cycle clim-demo::lisp-listener :menu t :gesture :menu)
    (object)
  (list object))

(define-drag-and-drop-translator besides
    (picture command picture clim-demo::lisp-listener
             :tester ((object destination-object)
                      (not (eq object destination-object))))
    (object destination-object)
  `(clim-demo::com-beside ,object ,destination-object))
From: Gareth McCaughan
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <87r7k2ordd.fsf@g.mccaughan.ntlworld.com>
Rainer Joswig wrote:

> A picture of playing around with the code in LispWorks CLIM
> on my iMac G5:
> 
> http://lispm.dyndns.org/lisp/pics/fg.jpg

"Connection refused".

-- 
Gareth McCaughan
.sig under construc
From: Geoffrey Summerhayes
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <VqYMd.4693$lw4.1005455@news20.bellglobal.com>
"Rainer Joswig" <······@lisp.de> wrote in message ·································@news-50.dca.giganews.com...
> In article <············@newsreader2.netcologne.de>,
> Frank Buss <··@frank-buss.de> wrote:
>
>> I never really understood how to use higher order functions as combinators,
>> until I read the article from Peter Henderson about Functional Geometry.
>> Now it is easy for me to use it in Lisp:
>>
>> http://www.frank-buss.de/lisp/functional.html
>> http://www.frank-buss.de/lisp/fishes.pdf
>
> A picture of playing around with the code in LispWorks CLIM
> on my iMac G5:
>
> http://lispm.dyndns.org/lisp/pics/fg.jpg
>
> Note that you can have commands to manipulate pictures
> (via command line, menus or even drag&drop) and
> that CLIM can generate postscript.
>

Well, here's my shot LW-CAPI:

http://www.summerhayes.ca/pics/screen1.png

Still playing with it, used the SICP code for a base, if anyone's
interested I'll put the code up.

--
Geoff
From: Frank Buss
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <cu1mtm$eam$1@newsreader2.netcologne.de>
"Geoffrey Summerhayes" <·······@NhOoStPmAaMil.com> wrote:

> Well, here's my shot LW-CAPI:
> 
> http://www.summerhayes.ca/pics/screen1.png

That's great! In color and with curves and looks like you are managed to 
use only one fish form.

> Still playing with it, used the SICP code for a base, if anyone's
> interested I'll put the code up.

yes, I'm interested. Currently I'm trying CAPI, too, for game programming:

http://www.frank-buss.de/lisp/aqueduct.html

so perhaps I can learn something by reading your code.

-- 
Frank Bu�, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: GP lisper
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <1107684417.1eaf25fa9ff6784fdc4b3dad65033917@teranews>
On Sat, 5 Feb 2005 05:51:50 +0000 (UTC), <··@frank-buss.de> wrote:
> "Geoffrey Summerhayes" <·······@NhOoStPmAaMil.com> wrote:
>
>> Well, here's my shot LW-CAPI:
>> 
>> http://www.summerhayes.ca/pics/screen1.png
>
> That's great! In color and with curves and looks like you are managed to 
> use only one fish form.

Yes, he chose the other option (compared to Escher) to handle the
'triangles' from the incomplete tiling.  I ended up concluding that
the irregular forms of Escher contributed to the "beauty" of the
picture.  I wondered if that might be a general rule (to consider,
should you try to make other pictures).

I too would be interested in the source.

TIA


-- 
Everyman has three hearts;
one to show the world, one to show friends, and one only he knows.
From: Geoffrey Summerhayes
Subject: Re: Functional Geometry for fishes
Date: 
Message-ID: <ToENd.3664$Ub4.288045@news20.bellglobal.com>
"Frank Buss" <··@frank-buss.de> wrote in message ·················@newsreader2.netcologne.de...
> "Geoffrey Summerhayes" <·······@NhOoStPmAaMil.com> wrote:
>
>> Well, here's my shot LW-CAPI:
>>
>> http://www.summerhayes.ca/pics/screen1.png
>
> That's great! In color and with curves and looks like you are managed to
> use only one fish form.
>
>> Still playing with it, used the SICP code for a base, if anyone's
>> interested I'll put the code up.
>
> yes, I'm interested. Currently I'm trying CAPI, too, for game programming:
>
> http://www.frank-buss.de/lisp/aqueduct.html
>
> so perhaps I can learn something by reading your code.
>

Well it won't be learning anything about CAPI there's just enough there
to make the display.
Code's up

http://www.summerhayes.ca/files/painter.lisp.txt

--
Geoff