A  Quick  and  Dirty  PostScript
"Tuna Can" Transform
 

By Don Lancaster                                                                   
Version 1.1 December 5, 1997
Copyright c. 1997 by Don Lancaster and Synergetics, Box 809, Thatcher AZ, 85552
(520) 428-4073. synergetics@tinaja.com All commercial rights and all electronic media
rights are *fully* reserved. Linking welcome. Reposting is expressly forbidden.

Further support on www.tinaja.com  
Also see http://www.tinaja.com/info01.html


(The following is believed correct. Please report any errors or differing experiences.)

Somewhere in our 1800+ file backlog is a detailed and formal "tuna can" transform that
lets you use PostScript to create intentionally distorted "tuna can" like objects, where the
lettering clearly and cleanly wraps itself around a tilted cylinder. A tuna can transform
differs from isometric in that the tilt axis is less and is forward only. It is also nonlinear.

I needed a quick and dirty Tuna Can transform for figure 4 of Muse121, aka
http://www.tinaja.com/glib/muse121.pdf where a pair of rod magnets was shown, and
it was easier to throw together some new and crude code rather than finding the original.

The utterly fascinating general theory of PostScript nonlinear transforms appears in
http://www.tinaja.com/glib/nonlingr.pdf The tuna can is a nonlinear transform done
by intercepting and remapping each incidence of every moveto and lineto.

The detailed code example appears in http://www.tinaja.com/glib/muse121.psl. Here
is a tutorial excerpt:

     /!DD 4 def                        % magnet diameter
     /!TA 20 def                       % tilt angle in degrees
     /!KK !TA sin !DD mul 2 div def    % a transform variable
     /adj {3.1415 2 div mul} def       % use radius units not circum

     /tunaxf {                         % begin Tuna NLT def
        /yy exch store                 % save y position
        /xx exch store                 % save x position

        xx !DD div 114.591 mul sin     % do Tuna nonlinear transform
        !DD mul 2 div yy xx !DD div    % see nonlingr.pdf for math
        114.591 mul cos !KK mul sub
             } def

My Gonzo utilities are found at http://www.tinaja.com/psutils/gonzo20.ps
The "run" file must be customized for your folders. Be sure to use double slashes in
your PostScript filename string!

The easiest way to use this code is to edit it with Wordpad or whatever, save it as an
ASCII textfile
, and send it to Acrobat Distiller. More details on using Distiller as a
general purpose PostScript interperter are in http://www.tinaja.com/text/sixclick.html

The only non-trivial gonzo commands used are the showgrid used for the background layout
grid and the colorizing commands such as beige. The rest are obvious, with mt = moveto,
pu = path up, etc.

A "proper" tuna can transform would automatically eliminate any "corner cutting" by
intercepting all long horizontal moveto and lineto commands, and replacing them with
shorter curvetrace commands, which in turn are converted to short segments by
flattenpath. In this case, the can magnet cutting is eliminated by using lots of short
segments in the circumferental direction. The "N" is not quite right, but is small enough
that you cannot tell. Purty nigh but not plumb.

The key point of this tutorial is how easy it is to intercept positions and do nonlinear
transformations of just about any type.

More on this whenever.


Copyright c. 1997 by Don Lancaster and Synergetics, Box 809, Thatcher AZ, 85552
(520) 428-4073. synergetics@tinaja.com All commercial rights and all electronic media
rights are *fully* reserved. Linking welcome. Reposting is expressly forbidden.
Further support on http://www.tinaja.com
Consulting services available via don@tinaja.com
Also see http://www.tinaja.com/info01.html