Rs.XFormRotation2 bug?

Hi Steve
I have the below Python file saved with name

import rhinoscriptsyntax as rs
def a():
    print matrot
if __name__=="__main__":

if i run the script the the matrot is:
R0=(0.999876632481661,-0.0157073173118207,0,0), R1=(0.0157073173118207,0.999876632481661,0,0), R2=(0,0,1,0), R3=(0,0,0,1)

If i create a new below script that called matr , matrot is:
R0=(1,0,0,0), R1=(0,1,0,0), R2=(0,0,1,0), R3=(0,0,0,1)

import rhinoscriptsyntax as rs
import matr

this is a bug or my mistake?

Ciao Vittorio

Hi Steve or Dale
can you tell me if it’s a bug?
Ciao Vittorio

Is it possible that import matr is referencing a previous file or or an other version of the same file from memory?

Try doing the division with a float.
change 40 to 40.0


that should do the trick.


Thanks Miguel
you’re right, it should not be so
Ciao Vittorio

That is just the way python is going to have to work. The default behavior for python is to perform integer division when the numbers being divided are both integers. I switched this to perform floating point division when the module being run is the main module. When a module is imported, the behavior is the older integer division. This is done because I can’t tel where a module actually came from and some older modules (or ones in the standard library) may actually depend on this behavior.

If you want to force floating point division at all times in your module add

from __future__ import division

at the beginning of your script. If you google the above line, you’ll find plenty of articles on the subject.

1 Like

Ciao Steve
Thank for your explanation.
I invite you to partecipate at next RhinoDay in Padua in April month. Can you tell me the time that you are available?
Ciao Vittorio