Rotate a vector

I have a vector that I want to rotate so it points up at a 45 degree angle from its original direction. When I say "up" I mean so it is still traveling in the same direction except for on the y axis.


To rotate around the local right vector you can calculate it like this:

    // the Vector3 you want to rotate
    var myVector : Vector3; 

    // help vector that points to the right
    var right : Vector3 = Vector3.Cross(myVector,Vector3.up);

    // rotate myVector around right
    myVector = Quaternion.AngleAxis(45, right) * myVector;

Maybe not the best way, and maybe it doesn't even work (can't try it out right now, rebuilding my pc). But I'd try something like:

Quaternion offset = Quaternion.Inverse(Quaternion.FromToRotation(myVec, Vector3.forward));
Quaternion rotateUp = Quaternion.FromToRotation(Vector3.forward, Vector3.forward + Vector3.up);
myVec = (offset * rotateUp) * myVec;