Unity Community


Results 1 to 6 of 6

  1. Posts
    329

    how do you rotate a vector

    Is there some unity3d function that will rotate a vector and return a new vector.

    Like vector (5,0,0) rotated 0,180,90 degrees would return
    vector (0,5,0)?



    Thanks,

    Dan
    Trying to port cinematic sciences from blink3d to unity3d and working on other scientific applications using Unity.


  2. Location
    The Netherlands
    Posts
    1,023

    Re: how do you rotate a vector

    Quote Originally Posted by whimsica
    Is there some unity3d function that will rotate a vector and return a new vector.
    You can multiply the vector with the rotation:

    Code:  
    1. rotatedVector = Quaternion.Euler(0,180,90) * originalVector;

    Note: there is only one allowed order of multiplication. (I believe I got it right as rotation * vector, but I did not test the example).


  3. Posts
    329

    what can multiply what?

    That worked.

    Is there some documentation on quaternions and what you can do with them in terms of vector or quaternion math?

    For example can you multiply quaternions, what is the result?
    A quaternion multiplied by a vector3 what is the result?

    etc..

    Thanks.

    Dan
    Trying to port cinematic sciences from blink3d to unity3d and working on other scientific applications using Unity.


  4. Location
    The Netherlands
    Posts
    1,023

    Re: what can multiply what?

    Quote Originally Posted by whimsica
    For example can you multiply quaternions, what is the result?
    A quaternion multiplied by a vector3 what is the result?
    The Quaternion reference page does discuss the two possible multiplications:
    http://unity3d.com/support/documenta..._multiply.html

    It does, however, do it in the usual brief 'Unity reference style', which may not help you much if you don't already know what a quaternion is .


  5. Location
    NYC
    Posts
    978
    in which case there's always wikipedia
    http://en.wikipedia.org/wiki/Quaternion

    For example can you multiply quaternions, what is the result?
    it's a quaternion (representing a composite rotation of the 2 quaternion: rotate by the first quaternion and then by the second. Note multiplication is not commutative, just like the order in which you apply the rotations matters)
    A quaternion multiplied by a vector3 what is the result?
    it is a vector (rotated by the quaternion)


  6. Posts
    34
    I need help regarding rotating a vector using a quaternion.

    Code:  
    1. transform.position = position;
    2. transform.rotation = target.rotation;
    3. transform.Translate(0.75f, 0.80f, 2.10f);

    Code:  
    1. position += new Vector3(0.75f, 0.80f, 2.10f);
    2. transform.position = position;

    I would expect both codes to output similarly but it's not happening. Am I using the quaternion to rotate the vector wrongly?

Posting Permissions

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