# Calculate a new vector which is 20 degrees towards a new vector from an old vector

hi there having a problem calculating a new vector mainly due to my failing of understanding of vectors and Quaternions.

i have 3 points A, B and C and two vectors A->B and B->C,

i want to create a new vector which is vector AB rotated by 20 degrees towards vector BC.

what i have tried to do is get the cross product between the two vector to get a rotation axis then use Quaterion.AngleAxis, however i don’t know how to apply this to a vector3.

how would i go about doing this correctly?

thanks for any help

Ken.

here is my bad code if it helps

``````Vector3 newWirePoint;
Vector3 A = wirePoint[x-1]-wirePoint[x-2];
Vector3 B = anchorPos-wirePoint[x-1];
Vector3 AcrossB = Vector3.Cross(A,B);
newWirePoint = A.normalized * 0.05f;
newWirePoint = Quaternion.AngleAxis(20,AcrossB);
``````

You are nearly there!

`````` newWirePoint = Quaternion.AngleAxis(20, AcrossB) * newWirePoint;
``````

Found my own answer will leave post here so if anyone else has this issue.

here is my script

``````				float Omega = 0.35f;
Vector3 newWirePoint;
Vector3 A = wirePoint[x-1]-wirePoint[x-2];
Vector3 B = anchorPos-wirePoint[x-1];
Vector3 AcrossB = Vector3.Cross(A,B);
AcrossB = AcrossB.normalized;
newWirePoint = A*Mathf.Cos(Omega)+ Vector3.Cross(AcrossB,A)*Mathf.Sin(Omega)+ AcrossB*Vector3.Dot(AcrossB,A)*(1-Mathf.Cos(Omega));
newWirePoint = newWirePoint.normalized * 0.05f;
wirePoint[x] = wirePoint[x-1] + newWirePoint;
wireRender.SetVertexCount(x+1);
wireRender.SetPosition(x,wirePoint[x-1] + newWirePoint);
x++;