It is currently Wed Apr 24, 2024 4:59 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 59 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Need Help Testing A Simple Script
PostPosted: Sat Mar 14, 2015 11:43 pm  (#1) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5242
Location: Gimpville
This script calculates the horiz and vert direction based on the angle. I think we are seeing different results from different PCs. This test will allow us to check to see if the math is consistent across GIMP installs, OS, & Hardware.

1) Install the attached test-calc.scm script
2) Open any image and run Script-Fu/Test Calc
3) Post the results displayed on error console back to this thread.

Here are the results of my tests.

Image

Thanks!


Attachments:
File comment: Test Calc
test-calc.scm [3.84 KiB]
Downloaded 140 times

_________________
“If you reach for the stars, you just might land on a decently sized hill.” - Stuart Hill
Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 12:04 am  (#2) 
Offline
Global Moderator
User avatar

Joined: Oct 02, 2014
Posts: 4418
Location: Sydney Australia
Here are my test calc results -

Intel Celeron N282 Intel HD graphics 4GB memory Windows 8.1 64 bit GIMP 2.8.14

Image

_________________
Image

Respect should be offered freely but hard earned


Last edited by oldmangrumpy on Sun Mar 15, 2015 1:19 am, edited 1 time in total.

Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 1:01 am  (#3) 
Offline
Global Moderator
User avatar

Joined: Nov 16, 2011
Posts: 5128
Location: Metro Vancouver, BC
Gimp 2.8.14, Ubuntu 14.10
Memory: 2.0 GiB
Processor: Intel Core 2 Duo CPU T5550 @ 1.83GHz
Graphics: Intel GM965/GL960 x86/MMX/SSE2
OS type: 32-bit

Test Calc Warning
Angle(0) horz: 1 vert: 0

Test Calc Warning
Angle(45) horz: 1 vert: 1

Test Calc Warning
Angle(90) horz: 0 vert: 1

Test Calc Warning
Angle(135) horz: 0 vert: 1

Test Calc Warning
Angle(180) horz: 0 vert: 0

Test Calc Warning
Angle(225) horz: 0 vert: 0

Test Calc Warning
Angle(270) horz: 0 vert: 0

Test Calc Warning
Angle(315) horz: 1 vert: 0


Attachments:
File comment: Test results
obc-test-calc.txt.7z [226 Bytes]
Downloaded 107 times

_________________
Image
Gimp 2.8.18, Linux, median user
Gimp Chat Tutorials Index
Spirit Bear (Kermode)
Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 1:05 am  (#4) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
Here you are GnuTux

Test Calc Warning
Angle(0) horz: 1.0 vert: 0.0

Test Calc Warning
Angle(45) horz: 1.0 vert: 1.0

Test Calc Warning
Angle(90) horz: 0.0 vert: 1.0

Test Calc Warning
Angle(135) horz: -1.0 vert: 1.0

Test Calc Warning
Angle(180) horz: -1.0 vert: 0.0

Test Calc Warning
Angle(225) horz: -1.0 vert: -1.0

Test Calc Warning
Angle(270) horz: -0.0 vert: -1.0

Test Calc Warning
Angle(315) horz: 1.0 vert: -1.0

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 1:18 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12517
Below's my result Tux. :)

  Test Calc Warning
Angle(0)   horz: 1.0  vert: 0.0

  Test Calc Warning
Angle(45)   horz: 1.0  vert: 1.0

  Test Calc Warning
Angle(90)   horz: 0.0  vert: 1.0

  Test Calc Warning
Angle(135)   horz: -1.0  vert: 1.0

  Test Calc Warning
Angle(180)   horz: -1.0  vert: 0.0

  Test Calc Warning
Angle(225)   horz: -1.0  vert: -1.0

  Test Calc Warning
Angle(270)   horz: -0.0  vert: -1.0

  Test Calc Warning
Angle(315)   horz: 1.0  vert: -1.0

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 1:26 am  (#6) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5242
Location: Gimpville
Thanks for the tests.

So far, I see Odin is the odd man out. His system does not output the same values as the other results. I'll bet this will be the same as Issabella's results, when she has a chance to post them.

When I released the 3D Extrusion script, I certainly didn't expect that the internal calculations would yield different values across different PCs, but there it is. :(

(set! hpos (round (cos (* 225 (/ 3.14 180)))))
(set! vpos (round (sin (* 225 (/ 3.14 180)))))


On the machines in question, like Odin's, negative values end up being zero, instead of -1.

Anyone have any suggestions as to why this would be the case on certain machines?

_________________
“If you reach for the stars, you just might land on a decently sized hill.” - Stuart Hill


Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 1:41 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12517
Math Co-Processor error? I heard that there might be one on new Intel processors. See link below Tux. :)

https://randomascii.wordpress.com/2014/ ... intillion/

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 3:12 am  (#8) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
Looks like the round function isn't doing what's expected of it: http://www.scheme.com/tspl3/objects.html#./objects:s93

And I think the lack of decimal points is indicative of something being different.

If Odin would like to try opening the script-fu console and trying this:
(round -0.7)

I get the answer -1.0 on GIMP 2.8.14 on my Windows 8.1 machine
I get the answer -1 on GIMP 2.6.7 on my Windows 8.1 machine
I get the answer -1.0 on GIMP 2.8.14 on my Ubuntu 14.04 LTS virtual machine

Kevin

p.s. Script-Fu has a constant: *pi*

And just to throw in a possible reason for the different behaviour. If I add this to your test_calc script:
(define (round value)
  (* value 2)
)

I can redefine what the round function returns:
  Test Calc Warning
Angle(0)   horz: 2.0  vert: 0.0

  Test Calc Warning
Angle(45)   horz: 1.414776538  vert: 1.413650362

  Test Calc Warning
Angle(90)   horz: 0.001592653421  vert: 1.999999366

  Test Calc Warning
Angle(135)   horz: -1.41252329  vert: 1.415901817

  Test Calc Warning
Angle(180)   horz: -1.999997463  vert: 0.003185305833

  Test Calc Warning
Angle(225)   horz: -1.417026198  vert: -1.411395321

  Test Calc Warning
Angle(270)   horz: -0.004777956225  vert: -1.999994293

  Test Calc Warning
Angle(315)   horz: 1.410266458  vert: -1.418149681


So it could be another script redefining round for it's own purpose.


Last edited by paynekj on Sun Mar 15, 2015 4:04 am, edited 1 time in total.

Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 3:44 am  (#9) 
Offline
GimpChat Member
User avatar

Joined: Mar 01, 2014
Posts: 12656
Location: Spain, Aragón
Here my test Calc. Thanks GnuTux :)


Attachments:
Results-Issa.JPG
Results-Issa.JPG [ 73.39 KiB | Viewed 3111 times ]

_________________
Image

Gimp 2.10.30(samj) portable _ OS Windows 10 Home_ 64bits
Don’t be afraid to start over. It’s a new chance to rebuild what you want.
Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 4:05 am  (#10) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
@GnuTux
looks like Issabella and Odin's machines are truncating rather than rounding ..hence the lack of decimal places as well.


Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 4:42 am  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jun 24, 2010
Posts: 504
Location: Western Vic Australia
ImageHere is one more result, Gimp 2.6.11, Windows 7 home premium, x64.

_________________
Image


Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 5:51 am  (#12) 
Offline
GimpChat Member

Joined: Feb 09, 2015
Posts: 110
Attachment:
result.PNG
result.PNG [ 7.8 KiB | Viewed 1080 times ]

amd64/quad core/w7/2.8.14


Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 8:06 am  (#13) 
Offline
GimpChat Member
User avatar

Joined: Nov 09, 2011
Posts: 726
Hello.
Kubuntu Linux 14.04 64bits
intel i7 3770
Gimp 2.8.14
Image

_________________
Image
Be patient, English is not my language.


Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 8:14 am  (#14) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
Here's mine a bit late.

Image

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 8:40 am  (#15) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4739
Not sure this is a good way to obtain a direction. What happens for small angles (sin or cos <.5)?

You should be using the sign, and if there is no such function in Scheme, you can hack one by dividing the variable by its absolute value (with special case for 0).

But really, nothing wrong with something like

For vpos:

if (angle modulo 180) == 0 return 0
else if (angle modulo 360) > 180 return -1
else return +1


for hpos:
return vpos (angle-90)

_________________
Image


Last edited by ofnuts on Sun Mar 15, 2015 10:47 am, edited 2 times in total.

Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 10:27 am  (#16) 
Offline
Global Moderator
User avatar

Joined: Nov 16, 2011
Posts: 5128
Location: Metro Vancouver, BC
paynekj wrote:
Looks like the round function isn't doing what's expected of it: http://www.scheme.com/tspl3/objects.html#./objects:s93

And I think the lack of decimal points is indicative of something being different.

If Odin would like to try opening the script-fu console and trying this:
(round -0.7)

I get the answer -1.0 on GIMP 2.8.14 on my Windows 8.1 machine
I get the answer -1 on GIMP 2.6.7 on my Windows 8.1 machine
I get the answer -1.0 on GIMP 2.8.14 on my Ubuntu 14.04 LTS virtual machine

Kevin

p.s. Script-Fu has a constant: *pi*

And just to throw in a possible reason for the different behaviour. If I add this to your test_calc script:
(define (round value)
  (* value 2)
)

I can redefine what the round function returns:
  Test Calc Warning
Angle(0)   horz: 2.0  vert: 0.0

  Test Calc Warning
Angle(45)   horz: 1.414776538  vert: 1.413650362

  Test Calc Warning
Angle(90)   horz: 0.001592653421  vert: 1.999999366

  Test Calc Warning
Angle(135)   horz: -1.41252329  vert: 1.415901817

  Test Calc Warning
Angle(180)   horz: -1.999997463  vert: 0.003185305833

  Test Calc Warning
Angle(225)   horz: -1.417026198  vert: -1.411395321

  Test Calc Warning
Angle(270)   horz: -0.004777956225  vert: -1.999994293

  Test Calc Warning
Angle(315)   horz: 1.410266458  vert: -1.418149681


So it could be another script redefining round for it's own purpose.
Gimp 2.8.14, Ubuntu 14.10
> (round -0.7)
0

_________________
Image
Gimp 2.8.18, Linux, median user
Gimp Chat Tutorials Index
Spirit Bear (Kermode)


Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 10:50 am  (#17) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
ofnuts wrote:
Not sure this is a good way to obtain a direction. What happens for small angles (sin or cos <.5)?

This script can only produce extrusion at angles which are multiples of 45 degrees - at each step of the extrusion process it simply copies the existing layer to a new layer, translates it by {-1, 0 or +1} pixels in each of the x and y directions and then merges with the existing layer. The fact that the GUI allows you to enter intemediate angles is rather misleading - eg. if you enter 30 degrees it will just round down to 0; if you enter 31 degrees it will round up to 45.
So it may just as well be done with a look-up table anyway!

But that's missing the point vis-a-vis the math problem - the (round x) function should work and it should work the same on all platforms.


Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 11:20 am  (#18) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
paynekj wrote:
So it could be another script redefining round for it's own purpose.

Could you (or Oregonian, or Isabella) open up the Script-fu console ("Filters->Script-fu->Console") and report what is displayed if you type "round" by itself (no quotes)?

If the output is:
#<round PROCEDURE 66>
then 'round' has not been redefined by another script. However, if the output is:
#<CLOSURE>
then it has been re-defined.

For the latter case, please type the following command into the console and report what is displayed:
(get-closure-code round)

(This will display the new definition which might prove useful in tracking down what script has re-defined it. At least it will show the faulty definition.)

Odinbc wrote:
Gimp 2.8.14, Ubuntu 14.10
> (round -0.7)
0

If the problem is not owing to re-definition of 'round', please open the GIMP Python console ("Filters->Python-Fu->Console") and see if the function behaves there:
round( -0.7)

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 11:38 am  (#19) 
Offline
Global Moderator
User avatar

Joined: Nov 16, 2011
Posts: 5128
Location: Metro Vancouver, BC
GIMP 2.8.14 Python Console
Python 2.7.8 (default, Oct 20 2014, 15:05:29)
[GCC 4.9.1]
>>> round( -0.7)
-1.0

_________________
Image
Gimp 2.8.18, Linux, median user
Gimp Chat Tutorials Index
Spirit Bear (Kermode)


Top
 Post subject: Re: Need Help Testing A Simple Script
PostPosted: Sun Mar 15, 2015 11:46 am  (#20) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Oops, the first sentence in my preceding post should have been directed at Odinbc. I hadn't realized that he was quoting paynekj.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
Post new topic Reply to topic  [ 59 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) My Experiments On GMIC Testing filters: Simple Graphics (now 14)

1046

No new posts Attachment(s) Amazing what can be found under testing

30

No new posts Testing Gmic-Qt Standalone 3.1

4

No new posts Attachment(s) questions about testing with DIEGO_Render_FillingPlus

13

No new posts Attachment(s) New layer modes in LayerFX-2.10 for testing.

9



* Login  



Powered by phpBB3 © phpBB Group