Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Quaternions in Inspector/Editor?

Discussion in 'General Discussion' started by JovanD, Mar 5, 2015.

  1. JovanD

    JovanD

    Joined:
    Jan 5, 2014
    Posts:
    206
    So i want to learn more about and "get used to" Quaternions, but i feel like Euler based rotation gizmo and inspector would impede that. So is there any asset out there that changes the rotation gizmo to Quaternion angles? And would such asset even be possible to create?
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,734
    It would be relatively simple just to expose the x, y, z and w components of a quaternion in the inspector. There is a very good reason not to do this.

    Quaternions represent rotations in four dimensions using imaginary space. Most human minds have trouble visualising 4D space effectively. 4D imaginary space makes even less sense. Creating a gizmo to represent this on the screen will be difficult to impossible. 3D on a 2D screen is rough enough, can you imagine a 4D gizmo.

    So yes, it totally can be done. But I'd suggest not doing it. Even high level mathematicians tend not to work with quaternion values directly.
     
    wccrawford and zombiegorilla like this.
  3. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,230
    What BoredMormon said.

    Changing the transform inspector is relatively trivial. The gizmo may be trickier. Quaternions don't translate well to human interpretable stuff. I can give you a chunk of code for the inspector, but really, you can just switch to debug mode to see XYZW. That way leads to madness. ;)
     
    Kiwasi likes this.
  4. JovanD

    JovanD

    Joined:
    Jan 5, 2014
    Posts:
    206
    Tnx for reply, i noticed the debug mode. Guess it's better to settle for Quaternion.Euler and feel like a scrub for now :p
     
  5. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,230
    No need to feel that way at all. That is what eulars are for. One of engineers is a math Phd. and fully groks quaternions (but can't explain them very well). Even so, he never writes anything that uses them directly, always eulers. I figure if he doesn't need to, I don't. ;)
     
    Kiwasi likes this.
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,734
    This.

    I understood quaternions once. (Got bachelors level maths, not PhD, so its not as hard as some people make it out). Trouble is that even understanding them still doesn't give you an easy way to visualise what a given quaternion means. If you ever do use quaternions you'll probably find that you are algebraically manipulating them, rather then directly touching the values. So far I haven't seen a use case that would justify the effort of learning to manipulate quaternion values directly.
     
  7. LarryTheBrave

    LarryTheBrave

    Joined:
    Nov 20, 2016
    Posts:
    19
    There is a tool online that shows quaternions like a normal rotation and what the numbers look like both ways. The space is not really imaginary per se, it's just having a number line going in 4 different perpendicular dimensions and projecting into 3D space from a hypersphere. Even there is a Microsoft Store application that was made with Unity(!) showing quaternion rotation so I beg to differ. I just feel like when you get a transform you should get the reading as Euler angles and only convert to quaternions if you really need to.
     
  8. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    16,218
    Guessing you're referring to this one?

    https://quaternions.online/
     
unityunity