[RESOLED] Possible bugs fx trig functions

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

[RESOLED] Possible bugs fx trig functions

Post by fmw42 »

It would seem that in IM 6.9.9.40 and 7.0.7.28 (Mac OSX Sierra) that arcsin and arccos are reversed.

y=0
convert xc: -format "%[fx:acos(y)]\n" info:
0
convert xc: -format "%[fx:asin(y)]\n" info:
1.5708 = pi/2


y=0
magick xc: -format "%[fx:acos(y)]\n" info:
0
magick xc: -format "%[fx:asin(y)]\n" info:
1.5708 = pi/2

But properly arcos(0) is pi/2 and arcsin(0) is 0

See wikipedia graphs at https://en.wikipedia.org/wiki/Inverse_t ... _functions

The above is also obvious since we know that sin(0)=0, so arcsin(0) = 0. And we know that cos(pi/2)=0, so that arccos(0)=pi/2


Checking: the sin(0) should be 0 and the cos(0) should be 1. But in fx, I get

y=0
convert xc: -format "%[fx:sin(y)]\n" info:
0.841471
convert xc: -format "%[fx:cos(y)]\n" info:
0.540302

which are nonsense values.. Likewise for IM 7 with magick.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Possible bugs fx trig functions

Post by snibgo »

Umm, Fred, are you using "acos(y)" etc? Then you are not using the environment variable $y.

I get the correct results with v7.0.6-28, pre-built binary on Windows 8.1:

Code: Select all

f:\web\im>%IMG7%magick xc: -format "%[fx:acos(0)]\n" info:
1.5708

f:\web\im>%IMG7%magick xc: -format "%[fx:asin(0)]\n" info:
0

f:\web\im>%IMG7%magick convert xc: -format "%[fx:acos(0)]\n" info:
1.5708

f:\web\im>%IMG7%magick convert xc: -format "%[fx:sin(0)]\n" info:
0
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Possible bugs fx trig functions

Post by fmw42 »

DOH! :oops: Staring at that for hours and missed it.

Thanks.
Post Reply