Bug 157497

Summary: atan operator gives wrong result range
Product: [Unmaintained] kpdf Reporter: Martin von Gagern <Martin.vGagern>
Component: generalAssignee: Albert Astals Cid <aacid>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 0.5.7   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Test case

Description Martin von Gagern 2008-02-09 11:32:13 UTC
Version:           0.5.7 (using 3.5.7, Gentoo)
Compiler:          gcc version 3.4.6 (Gentoo 3.4.6-r2, ssp-3.4.6-1.0, pie-8.7.10)
OS:                Linux (i686) release 2.6.22-gentoo-r9

Type 4 PDF functions can use the PostScript operator "atan" which roughly corresponds to the libc atan2 function. However, its result should be in degrees between 0 and 360. kpdf seems to calculate a range between -pi and pi. For the details of this operator, the PDF specification references the PostScript Language Reference, third edition, where the atan operator is described in detail on page 535 [1]. I'll attach a test case.

[1] http://www.adobe.com/products/postscript/pdfs/PLRM.pdf
Comment 1 Martin von Gagern 2008-02-09 11:37:00 UTC
Created attachment 23496 [details]
Test case

This test case does something like a conical gradient using a shading based on
a Type 4 function. Originally the result of atan was divided by 90, but this
yields almost black on kpdf. By changing the denominator to 5, the gradient is
recognizable, while still being not too thin in the correct rendering of e.g.
acroread. The rendering of kpdf and acroread can therefore be compared easily.
Comment 2 Albert Astals Cid 2008-02-09 12:25:20 UTC
SVN commit 772669 by aacid:

atan operator must yield a degrees result between 0 and 360

BUG: 157497


 M  +4 -2      Function.cc  


WebSVN link: http://websvn.kde.org/?view=rev&revision=772669
Comment 3 Martin von Gagern 2008-02-09 12:42:45 UTC
That was fast! Looking at the code in svn, however, it looks like sin and cos were dealing in radians as well, so they should be modified as well in order to accept an argument given in degrees, as the PostScript reference states.
Comment 4 Albert Astals Cid 2008-02-09 13:40:43 UTC
SVN commit 772693 by aacid:

PS cos and sin input values are degrees so convert to radians so we can use the cos and sin cmath functions
CCBUG: 157497


 M  +2 -2      Function.cc  


WebSVN link: http://websvn.kde.org/?view=rev&revision=772693