Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Functional Geometry for fishes

87 views
Skip to first unread message

Frank Buss

unread,
Jan 23, 2005, 1:17:44 PM1/23/05
to
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ß, f...@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de

Rainer Joswig

unread,
Jan 23, 2005, 2:18:14 PM1/23/05
to
In article <ct0po8$57m$1...@newsreader2.netcologne.de>,
Frank Buss <f...@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.

Emre Sevinc

unread,
Jan 23, 2005, 3:34:45 PM1/23/05
to
Frank Buss <f...@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

Marc Battyani

unread,
Jan 23, 2005, 4:11:11 PM1/23/05
to

"Emre Sevinc" <em...@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


Rainer Joswig

unread,
Jan 23, 2005, 4:33:39 PM1/23/05
to
In article <ct13tb$o...@library2.airnews.net>,
"Marc Battyani" <Marc.B...@fractalconcept.com> wrote:

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/).

Marc Battyani

unread,
Jan 23, 2005, 4:54:36 PM1/23/05
to

"Rainer Joswig" <jos...@lisp.de> wrote
> "Marc Battyani" <Marc.B...@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


Trent Buck

unread,
Jan 23, 2005, 10:14:22 PM1/23/05
to
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

Frank Buss

unread,
Jan 23, 2005, 11:28:53 PM1/23/05
to
Trent Buck <gera...@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

GP lisper

unread,
Jan 24, 2005, 9:24:13 AM1/24/05
to
On Mon, 24 Jan 2005 04:28:53 +0000 (UTC), <f...@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.

Geoffrey Summerhayes

unread,
Jan 27, 2005, 2:35:34 AM1/27/05
to

"GP lisper" <spam...@CloudDancer.com> wrote in message news:1106576653.d99305b82a9725848d1fded3b202ba9a@teranews...

> On Mon, 24 Jan 2005 04:28:53 +0000 (UTC), <f...@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


Rainer Joswig

unread,
Jan 29, 2005, 11:42:17 PM1/29/05
to
In article <ct0po8$57m$1...@newsreader2.netcologne.de>,
Frank Buss <f...@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))

Gareth McCaughan

unread,
Jan 30, 2005, 10:46:58 AM1/30/05
to
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

Geoffrey Summerhayes

unread,
Feb 5, 2005, 12:01:47 AM2/5/05
to

"Rainer Joswig" <jos...@lisp.de> wrote in message news:joswig-3B29C8....@news-50.dca.giganews.com...

> In article <ct0po8$57m$1...@newsreader2.netcologne.de>,
> Frank Buss <f...@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


Frank Buss

unread,
Feb 5, 2005, 12:51:50 AM2/5/05
to
"Geoffrey Summerhayes" <sum...@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 Buss

unread,
Feb 5, 2005, 1:07:36 AM2/5/05
to
GP lisper <spam...@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.

GP lisper

unread,
Feb 6, 2005, 5:06:55 AM2/6/05
to
On Sat, 5 Feb 2005 05:51:50 +0000 (UTC), <f...@frank-buss.de> wrote:
> "Geoffrey Summerhayes" <sum...@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

GP lisper

unread,
Feb 6, 2005, 5:21:16 AM2/6/05
to
On Sat, 5 Feb 2005 06:07:36 +0000 (UTC), <f...@frank-buss.de> wrote:
> GP lisper <spam...@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.

Geoffrey Summerhayes

unread,
Feb 7, 2005, 2:03:11 AM2/7/05
to

"Frank Buss" <f...@frank-buss.de> wrote in message news:cu1mtm$eam$1...@newsreader2.netcologne.de...

> "Geoffrey Summerhayes" <sum...@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


0 new messages