I have a known Vector3 (Yellow) and a known transform.forward (Blue). How do I rotate my Vector3 to the Pink one whist maintaining its current angle?

Drawing of epicness…

I have a known Vector3 (Yellow) and a known transform.forward (Blue). How do I rotate my Vector3 to the Pink one whist maintaining its current angle?

Drawing of epicness…

If it’s really just about that vector, and not a complete transform or GameObject or something, you can just construct your pink vector from scratch:

```
// find yellow's angle relative to up vector
float angle=Vector3.Angle(Vector3.up,yellow);
// create vector along up, and rotate it downwards by angle in the up/blue plane
Vector3 pink=Quaternion.AngleAxis(angle,transform.right)*Vector3.up; // transform.right is the normal of the up/blue plane
// if the length of your yellow vector is not 1, you then need to do this:
pink*=yellow.magnitude;
```

If this does not give you the desired result, I’ll construct the more complex variant, which first needs to figure out the signed angle of the up/yellow plane in respect to the up/blue plane, and then rotates yellow around up using that angle.

EDIT: this worked only for normalized vectors. I added more code for arbitrary length vectors.

If I understand your drawing correctly, what you want is an angle/axis rotation. Use Quaternion.AngleAxis() with your blue vector as the axis, and the angle the rotation between yellow and pink. Then you can multiply the quaternion by your vector3. For example assuming all vectors from the origin and a 25 degree rotation (untested):

```
Quaternion q = Quaternion.AngleAxis(25.0f, v3Blue);
Vector3 v3Pink = q * v3Yellow;
```

If the vectors are not form the origin, subtract out the initial position before the rotation and add it back after.