%% POSTSCRIPT ASIN AND ACOS OPERATORS %% ================================== %% Copyright c 2001 by Don Lancaster and Synergetics, Box 809, Thatcher, AZ %% 85552. (520) 428-4073. mailto:don@tinaja.com %% All commercial and all media rights ~fully~ reserved. Additional support at %% http://www.tinaja.com/post01.asp and http://www.tinaja.com/info01.asp %% These four PostScript utilities generate arcsine and arccos capabilities, %% both in traditional "atan" and more convenient formats. Predefine them before %% use in your PostScript code. %% "arc" or "inverse" operators are used in trig to get from a sine, cosine, %% tangent, or other function value to the underlying primary angle in degrees. %% For instance, arcsine (0.5) would be 30 degrees. Only the atan operator is %% initially defined in PostScript. %% These utilities work by "completing the triangle" of sides x and y and %% hypoteneuse (x^2 + y^2)^0.5 and then calling PS atan given x and y. %% The first two utilities are in the same format as the existing PostScript %% atan operator. Input TWO triangle sides as noted... /acos {2 copy dup mul exch dup mul sub sqrt exch pop exch atan} def % arccosine use - xside hypotenuse acos - /asin {2 copy dup mul exch dup mul sub sqrt exch pop atan} def % arcsine use - yside hypotenuse asin - %% These two utilities are in a more convenient "input trig, get degrees" format. %% They call the above two procs.. /trig.acos {1 acos} def % arcosine from input of trig value /trig.asin {1 asin} def % arcosine from input of trig value %% Demo -- Send to Distiller. Remove or alter before reuse -- 1 2 acos == 1 2 asin == 0 1 acos == 0 1 asin == 0.5 trig.acos == 1 trig.acos == 0 trig.acos == 0.5 trig.asin == 1 trig.asin == 0 trig.asin == %% results should be 60.0 30.0 90.0 0.0 60.0 0.0 90.0 30.0 90.0 0.0