In the function drawto, there is a line
Code: Select all
newy ypos sub newx xpos sub atan neg 90 add /orient exch def
But anyways, I can read postscript a little, but that line doesn't make sense to me. Why is it in there? When I hand edit the postscript file to comment out that line, I can create the PDF without problem.
Sample code that shows the error:
Code: Select all
(define pi (mul 4 (atan 1)))
(define (rad d) (mul d (div pi 180)))
(define (deg r) (mul r (div 180 pi)))
(module "postscript.lsp")
;; I work in inches as my base unit (72 points per inch), but scale things down
;; by scalefactor so they fit on a regular sheet of paper.
(define scalefactor 4)
(ps:scale (div 72 scalefactor) (div 72 scalefactor))
(define ¼ 0.25)
(define ½ 0.5)
(define origx (mul ½ 8.5 scalefactor))
(define origy (mul ½ 11 scalefactor))
(define my-goto (lambda (x y) (ps:goto (add x origx) (add y origy))))
(define my-drawto (lambda (x y) (ps:drawto (add x origx) (add y origy))))
;; https://math.stackexchange.com/questions/76099/polar-form-of-a-superellipse
;; answered Oct 26 2011 at 17:03 by Ross Millikan
;; polar coordinate form of a superellipse
;; r = ab/(|b cos theta|^n + |a sin theta|^n)^(1/n)
;; a is half the height
;; b is half the width
;; n is the exponent of the superellipse
(define super-ellipse-radius (lambda (a b n theta)
(div (mul a b)
(pow (add (pow (abs (mul b (cos theta))) n)
(pow (abs (mul a (sin theta))) n))
(div n)))))
(define draw-super-ellipse (lambda (a b n)
(letn (anglestep (rad 0.1)
ab (mul a b)
startr (super-ellipse-radius a b n 0)
startx (mul startr (cos 0))
starty (mul startr (sin 0)))
(my-goto startx starty)
(for (theta anglestep (mul 2 pi) anglestep)
(let (r (super-ellipse-radius a b n theta))
(my-drawto (mul r (cos theta)) (mul r (sin theta)))))
(my-drawto startx starty))))
(draw-super-ellipse (mul 7 (sqrt 2)) 7 2.718)
(ps:render "standing-desk2.ps")
(! "pstopdf standing-desk2.ps")
(exit)
Code: Select all
%%[ Error: undefinedresult; OffendingCommand: atan; ErrorInfo: CharOffsets %%[ Flushing: rest of job (to end-of-file) will be ignored ]%%
%%[ Warning: PostScript error. No PDF file produced. ] %%
pstopdf failed on file standing-desk2.ps with error code -31000