Results 1 to 12 of 12

Thread: API: setRotation() what coordinate system is used?

  1. #1

    Question API: setRotation() what coordinate system is used?

    What coordinate system are the functions setRotation() and rotate() using? To what does the degree for {x,y,z} relate???
    It is really awkward it seems like the rotation is at some point switching axis(!) which is highly confusing. I made an object with a script to turn +10 degrees per second for the y-axis which worked fine. But then I flipped the object and it turned still in the same direction from my point of view??? Why?
    Also when I put the objects sideways it still turns around the same axis like before instead in the xy-plain which I have set up for the object. I assumed that we would get and set local object coordinates whit those function but obviously I am wrong. So please tell me developers what system are you relating to for the rotation?

  2. #2
    Sounds like it is always relative to the surface plane of the board. To be honest, anything else would be confusing (to me anyway).

    I understand what you're expecting, that everything will be relative to the object. I see that as being *very* difficult to code. Imagine rotating a 12 or 20 sided die that is sitting on one of the sloped sides. It's not easy to picture what exactly it would look like. I think it would start rolling in a circle.

  3. #3
    APIs are in first place there for one thing: CONTROL!

    Convenience can be wrapped in other functions if desired. APIs should offer the sensibly smallest parts of functions and not ease you into comfort.

    In fact I found out that the rotation APIs are conditionally(!!!) changing the input of the parameters, depending on certain degree values! Now THAT is confusing and "*very* difficult to code" with because that makes everything unpredictable because underneath there are undocumented behaviors. This imposed 'convenience' has the side effect that one rotation axis is linear dependent of the other axis. Than means in non mathematical terms that this API offers only 2 axis of rotation which makes it impossible to take full control of an in game item.

    TL;DR: no, it is definitely not easier to have it that way, not at all!
    Last edited by FragaholiC; 03-04-2016 at 02:17 PM.

  4. #4
    Join Date
    Feb 2016
    Location
    Sweden
    Posts
    77
    It also seems that if you rotate an object 10 in the x-axis each frame, then once it reaches > 90 it will rotate back and get stuck in an endless wiggle.
    This effect is also visible while using the rotate gizmo, in all axes.

  5. #5
    Quote Originally Posted by slamakans View Post
    It also seems that if you rotate an object 10 in the x-axis each frame, then once it reaches > 90 it will rotate back and get stuck in an endless wiggle.
    This effect is also visible while using the rotate gizmo, in all axes.
    I know, but there is so much going on I didn't mention every detail. xD
    But I posted it in the scripting thread.

  6. #6
    Join Date
    Jan 2014
    Posts
    986
    We are using Unity's default transform for all object rotation / positioning.

    http://docs.unity3d.com/ScriptReference/Transform.html

  7. #7
    Join Date
    Feb 2016
    Location
    Sweden
    Posts
    77
    Quote Originally Posted by Knil View Post
    We are using Unity's default transform for all object rotation / positioning.

    http://docs.unity3d.com/ScriptReference/Transform.html
    Which function are you using for rotation, specifically?

  8. #8
    I think the only viable rotation function is this one, because it is the only in the list which gives you the full rotation and not only of one axis:
    http://docs.unity3d.com/ScriptRefere...rm.Rotate.html

  9. #9
    Join Date
    Feb 2016
    Location
    Sweden
    Posts
    77
    Quote Originally Posted by FragaholiC View Post
    I think the only viable rotation function is this one, because it is the only in the list which gives you the full rotation and not only of one axis:
    http://docs.unity3d.com/ScriptRefere...rm.Rotate.html
    There are multiple ways to rotate an object using the Transform and Quaternion classes, but as long as you stay away from eulerAngles things should be fine.

  10. #10
    Join Date
    Jan 2014
    Posts
    986
    Ya we exposed the euler rotations for ease of use we can look into offering support for quaternions in the future to avoid things like gimbal lock.

  11. #11
    Join Date
    Feb 2016
    Location
    Sweden
    Posts
    77
    Neat.

  12. #12
    Quote Originally Posted by slamakans View Post
    There are multiple ways to rotate an object using the Transform and Quaternion classes, but as long as you stay away from eulerAngles things should be fine.
    Well, as what I described in the scripting thread I experienced a gimble lock and therefore I assumed those are euler angles. So that is why I thought it must be that function. Also that was the only function, aside the single axis rotation, which could rotate.

    BUT: That wiggle that you and me described, this is not an euler angle specific problem I suppose, just some conversions getting crazy on a value limit I guess?

    @Knil
    Neat indeed.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •