Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Quaternion strange behaviour

Discussion in 'Entity Component System' started by eizenhorn, Aug 21, 2018.

  1. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    Hi!

    Faced with some strangeness, which I did not notice in the previous version of the Mathematics library. With a simple rotation of 90 degrees, it does not rotate by 90 degrees :) Actually the problem can be seen in the picture below.

    upload_2018-8-21_9-3-24.png

    upload_2018-8-21_9-2-43.png
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,754
    You got nice math :p
    I got few thoughts.
    - Either unity messed new Quaternion with latest preview 10 (which not meant to be public :cool:)
    - Or instead of Euler degrees is using radians. (double check)
    - Or your model is broken (joking)
    - Try revert to previous preview?
     
  3. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    I always use latest. Model of course fine. Radians is what i think first. And after testing is true...now we must devide Pi, 2Pi, etc. or use default math tables :D
    upload_2018-8-21_9-56-18.png
     
    LazyMonkey likes this.
  4. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    Looks like it's eventually using Sin and Cos (not degrees) try converting from degrees to radians first.

    EDIT: I was too slow! But, it looks like there are functions to convert between.

    math.radians(float) = Deg2Rad
    math.degrees(float) Rad2Deg
     
  5. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,683
    This uses radians now :) Pi/2 == 90*, Pi/2 45* etc. Of course, they can also be expressed through the sine of the cosine, and so on.
     
  6. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,754
    As degrees are convenient, I am glad Unity changed to radians. A bit, to get gain on some performance. Specially with lots of quaternions calculations, if anyone needs.