Python tag wrong angle output in console
-
Hello,
In a character rig I'm currently making, I need to do some calculations with some rotations of specific joints. In one of my python tags I was printing the pitching of the thigh joint into the console, but I got a very strange value (3.82°) while the coördinate manager says it's still at 0°, no matter if I view it in absolute, relative or world mode. Also, as soon as the thigh joint gets rotated (due to the hip joint moving downwards, or the foot controller moving upwards), the value changes from this weird angle, to the correct one. So it is working, as long as my thigh joint isn't at 0°, which it is at the start of my setup. Needless to say that I want it to work when it is 0° as well.
I have reverted to the saved project, and added my code again, and got the same problem. I then tried it out on a previous version of my rig, and I had the same problem, only now with a different value: 2.97°.
After that I did some more testing, and it seems that quite a lot of my joints give those strange values, when they should be at zero. And other joints just act normal.Attached are 2 screenshots, showing the python output, the selected thigh joint (in the viewport and object manager) and the relevant python code (also selected, on the ankle joint object) all in one.
I have also attached 2 files of my rig, so you can see it for yourself.
Moving the hip joint down, or the foot controller up, will update the angle of the thigh joint, and of course the output in the console.If you have any further questions, be sure to ask me!
LRRH_Rig_008.c4d
LRRH_Rig_007_T.c4dThanks in advance for your help and time!
With kind regards,Casimir Smets
-
Hello @csmets,
Thank you for reaching out to us. The value you see there is not 3.82° but (almost) zero degrees, as you are looking there at a value in scientific notation. The fact that the value is not exactly zero is likely caused by floating point precision errors which are unavoidable. But you can
round
values if you want to.3.82e-13
is just another way of writing0.000000000000382
, i.e., you have to shift the comma by 13 places. Which is why this script will run as follows:>>> a: float = 0.001 >>> b: float = 1.0E-3 >>> a 0.001 >>> b 0.001 >>> a == b True
For very small numbers Python will simply switch automatically to scientific mode when a number is printed.
>>> a: float = 0.000000000000000000000000000000000000001 >>> a 1e-39
Cheers,
Ferdinand -
Hi Ferdinand,
Thanks for your in-depth answer!
Cheers,
Casimir Smets