Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Python tag wrong angle output in console

    Cinema 4D SDK
    python
    2
    3
    352
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      csmets
      last edited by

      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!

      Screenshot 2022-10-24 at 15.10.54.png
      Screenshot 2022-10-24 at 15.50.10.png

      LRRH_Rig_008.c4d
      LRRH_Rig_007_T.c4d

      Thanks in advance for your help and time!
      With kind regards,

      Casimir Smets

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @csmets
        last edited by ferdinand

        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 writing 0.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

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • C
          csmets
          last edited by

          Hi Ferdinand,

          Thanks for your in-depth answer!

          Cheers,
          Casimir Smets

          1 Reply Last reply Reply Quote 0
          • First post
            Last post