Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Live Free or Live in Massachusetts.


devel / comp.lang.postscript / Re: Drawing Archimedes Spiral in PS

SubjectAuthor
o Re: Drawing Archimedes Spiral in PSjdaw1

1
Re: Drawing Archimedes Spiral in PS

<d123f34d-341a-4819-8e7e-ceda30c73ac5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10010&group=comp.lang.postscript#10010

  copy link   Newsgroups: comp.lang.postscript
X-Received: by 2002:ad4:5ccf:0:b0:474:7201:6789 with SMTP id iu15-20020ad45ccf000000b0047472016789mr17853735qvb.75.1659997470250;
Mon, 08 Aug 2022 15:24:30 -0700 (PDT)
X-Received: by 2002:a05:6870:b410:b0:115:fd56:bf9 with SMTP id
x16-20020a056870b41000b00115fd560bf9mr2620239oap.105.1659997469888; Mon, 08
Aug 2022 15:24:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.postscript
Date: Mon, 8 Aug 2022 15:24:29 -0700 (PDT)
In-Reply-To: <c1.2b5.2MLHPX$00x@204.49.39.22>#1/1>
Injection-Info: google-groups.googlegroups.com; posting-host=185.176.160.84; posting-account=Cp97SgoAAAC0t1Gya5PaPqyoafMoOtAn
NNTP-Posting-Host: 185.176.160.84
References: <6prq9h$gph$1@news.utdallas.edu> <c1.2b5.2MLHPX$00x@204.49.39.22>#1/1>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d123f34d-341a-4819-8e7e-ceda30c73ac5n@googlegroups.com>
Subject: Re: Drawing Archimedes Spiral in PS
From: jdawise...@gmail.com (jdaw1)
Injection-Date: Mon, 08 Aug 2022 22:24:30 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3354
 by: jdaw1 - Mon, 8 Aug 2022 22:24 UTC

This reply might be too late for the original poster; nonetheless might help later readers.

I needed (well, wanted) an Archimedean spiral, that is, a spiral in which radius is a fixed multiple of angle. It ‘needed’ to be pixel-precise, but also light, that is, not made of needlessly many pieces.

Of course it could be done with many small lineto’s. But that would not be light, and also, just yuck!.

So, curveto’s. Within the PostScript at
https://github.com/jdaw1/placemat/blob/main/PostScript/placemat.ps
is a command ArchimedeanSpiralPath.

It uses Bézier cubics that look like a part of a spiral (at most 45° of it). A Bézier cubic is specified by eight parameters. Naturally, it must go through the endpoints of the spiral fragment — consuming four parameters. At the start and end the slopes must be precisely tangent to the spiral — two more parameters. And, the cute extra two conditions: at each end the curvature of the Bézier must precisely match the curvature of the spiral.

So ArchimedeanSpiralPath calls ApproximatingCurve, which generates these fragments. Consider plotting a function parameterised as x(a), y(a). ApproximatingCurve takes, for the two end points, the values, single derivatives (wrt a) and double-derivatives, and returns the middle two control points of a curveto satisfying the location-slope-curvature conditions. It is a usefully general-purpose function.

ApproximatingCurve needs to solve several quartic equations. Solving high-order polynomials should be illegal in PostScript, but luckily isn’t, so is done with the function PolynomialRoots, called by ApproximatingCurve.

All of these are necessary, and also a few small pieces indicated in the comments.

ArchimedeanSpiralPath chooses close-ish angle separations for the innermost 180°, including √2 radians ≈ 81.028°, being the point at which curvature is maximal. Beyond 180° it uses multiples of 45°, for which the ApproximatingCurve is very very close.

Share and enjoy.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor