Search Unity

Rotating a vector around a certain point?

Discussion in 'Scripting' started by Bobfan, Sep 1, 2013.

  1. Bobfan

    Bobfan

    Joined:
    Mar 29, 2013
    Posts:
    3
    Currently, I am trying to rotate a vector around another point. So if I have one point at, let's say (0, 5, 1) and another point at (10, 21, 6), I would try to rotate the second point, about 45 degrees around the first point. Quaternion.Euler seems like the way to go, but I haven't had any luck getting it to work. Is there any chance someone could post an example or something?
     
    Last edited: Sep 1, 2013
  2. MaxRoetzler

    MaxRoetzler

    Joined:
    Jan 3, 2010
    Posts:
    136
  3. Bobfan

    Bobfan

    Joined:
    Mar 29, 2013
    Posts:
    3
    I guess I can just store the rotations as a transform, and convert them into a vector.
     
  4. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    1.translate so that the pivot is at origin
    2. rotate the vector point around the origin with someQuaternion*someVector
    3. translate back the same amount