\\ Copyright 2014 Kevin Ryde \\ \\ This file is free software; you can redistribute it and/or modify it \\ under the terms of the GNU General Public License as published by the Free \\ Software Foundation; either version 3, or (at your option) any later \\ version. \\ \\ This file is distributed in the hope that it will be useful, but \\ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY \\ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License \\ for more details. \\ \\ You should have received a copy of the GNU General Public License along \\ with this file. See the file COPYING. If not, see \\ . \\ Usage: gp dragon-unfold.gp \\ \\ Open a GUI window with a dragon curve plot to "level" expansion. \\ \\ Change plothraw() to psplothraw() to instead write PostScript to a \\ file "pari.ps". level = 13 p = [0, 1]; \\ complex number points, initially 0 to 1 \\ "unfold" by appending a copy of the p[i] coordinates pivoted at the \\ endpoint p[#p] and turning -90 degrees which is -I. \\ \\ * end \\ --> | \\ / | \\ v \\ *------->* \\ 0,0 p[#p] \\ for(i=1,level, my(end = (1+I)*p[#p]); \ p = concat(p, apply(z->(end - I*z), Vecrev(p[^-1])))) plothraw(apply(real,p),apply(imag,p), 1); \\ flag=1 join points