10 views

Skip to first unread message

Jul 31, 1998, 3:00:00 AM7/31/98

to

I need to make an archimedes spiral (one where the width bet. successive

turns remains the same)...of polar form r=a(theta). I need it to be very

large, like 22 inches in diameter. I don't care what program I do it in,

but I was thinking just writing a ps program might be the fastest. I was

able to make a spiral using Matlab's polar(r, 1.1*r) graphing command, but

I need something with a specific line width & span multiple pages since I

don't have a plotter. I found the Postscript Language Tutorial and

Cookbook, and I've made a square spiral (see below) but not a circular

one. Please help if you can. Thanks

turns remains the same)...of polar form r=a(theta). I need it to be very

large, like 22 inches in diameter. I don't care what program I do it in,

but I was thinking just writing a ps program might be the fastest. I was

able to make a spiral using Matlab's polar(r, 1.1*r) graphing command, but

I need something with a specific line width & span multiple pages since I

don't have a plotter. I found the Postscript Language Tutorial and

Cookbook, and I've made a square spiral (see below) but not a circular

one. Please help if you can. Thanks

/ptx 0 def

/pty 0 def

/nptx 0 def

/inch {72 mul} def

/drawline

{ newpath

ptx pty moveto

nptx pty lineto

stroke

} def

gsave

/nptx ptx 1 inch add def

5 inch 5.5 inch translate

1 1 19

{ 90 rotate

drawline

nptx pty translate

/nptx nptx .1 inch add def

} for

stroke

grestore

showpage

Jul 31, 1998, 3:00:00 AM7/31/98

to

In <6prq9h$gph$1...@news.utdallas.edu>, Joseph L Cordaro <jleo...@utdallas.edu> writes:

>I need to make an archimedes spiral (one where the width bet. successive

>turns remains the same)...of polar form r=a(theta). I need it to be very

>large, like 22 inches in diameter. I don't care what program I do it in,

>but I was thinking just writing a ps program might be the fastest. I was

>able to make a spiral using Matlab's polar(r, 1.1*r) graphing command, but

>I need something with a specific line width & span multiple pages since I

>don't have a plotter. I found the Postscript Language Tutorial and

>Cookbook, and I've made a square spiral (see below) but not a circular

>one. Please help if you can. Thanks

>

Here's a quick & dirty.>I need to make an archimedes spiral (one where the width bet. successive

>turns remains the same)...of polar form r=a(theta). I need it to be very

>large, like 22 inches in diameter. I don't care what program I do it in,

>but I was thinking just writing a ps program might be the fastest. I was

>able to make a spiral using Matlab's polar(r, 1.1*r) graphing command, but

>I need something with a specific line width & span multiple pages since I

>don't have a plotter. I found the Postscript Language Tutorial and

>Cookbook, and I've made a square spiral (see below) but not a circular

>one. Please help if you can. Thanks

>

Steve

%!

300 300 translate

0 0 moveto

0 .1 200 { dup 0 moveto .1 sub 0 lineto stroke 1 rotate } for

showpage

Aug 8, 2022, 6:24:30 PM8/8/22

to

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.

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.

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu