# Rotation of a random unit vector at a point in 3D space by an angle

I have a scenario where I need rotate a vector ( unit vector) at a point in space by an angle along Z-axis. Is it possible to help me to understand a procedure to achieve this. I'm using vb.net programming to do this programattically.

Here is the schematics for your understanding:

• angle along Z axis doesn't clarify plus you pictures don't even have labels for Axes. What is clarified is that you don't want to rotate around Z but along Z. Then there are only 2 options left either you want to rotate around X or Y. What do you want to do? Aug 17 '18 at 14:04
• Sorry for not adding the coordinates. I wish to transform the point P(x,y,z) to origin O(0,0,0) without varying the vector V(i,j,k) orientation. I then want to rotate along the vertical axis (Z) by an angle and move back to point P which would form Vector V'(i',j',k'). (This is based on many examples in internet). Kindly let me know if you need any further information for your suggestion a solution. If possible please provide a code snippet. Thank you Aug 19 '18 at 13:38
• let me phrase differently. Suppose the random vector is (1,0,0) which is your X-axis (assume front one). In this case, rotating along Z-axis (vertical axis) means you rotate the vector around Y-axis (right one). In another case let's say the vector is (0,1,0). Now rotating along Z means you rotate around X-axis. What exactly do you want in both cases? What happens when the vector is random? Aug 19 '18 at 14:10
• As far as I am aware "rotate along" has no meaning. Could you clarify what you want (and perhaps why), preferably with specific examples? "Rotate around" the z axis would mean that the z coordinate stays fixed. "Translate in the z direction" would mean that only the z coordinate changes. Are either of those what you meant by "rotate along"? Aug 19 '18 at 21:39
• I will rephrase my question: 1)I need to rotate the vector V with the base point P by an angle. 2) The rotation axis is say for now is about a local Y axis at point P 3) The local Y axis orientation is similar to the global Y axis. Hope there could be some solution to this. I'm programming in VB.net for a 3D point calculation project. Kindly provide me some insight to approach this problem. Thank you. Aug 22 '18 at 17:10

Rotation matrix | wikipedia.org in section that says "in three dimensions". It's the first search result when searching about rotating a vector about an axis. Let me know if you have any questions.

For your specific problem: bring the point P to the origin, then rotate the vector about the Z axis, then bring the point P back to its original location.

Thank you for the suggestions provided. As @gallickgunner mentioned, I shall rephrase the question will all the possible information which I could provide. I had attached also the schematic to depict my question.

1)I need to rotate the vector V with the base point P by an angle and find the new vector V'. 2) The rotation axis is say for is about a local y axis at point P (which is parallel to global Y axis) 3) Subsequently, I need to rotate the initial vector V about x axis which is parallel to global Y axis. The main reason for the rotation is to find the new vector V' at point P. Both the rotations are independent and each of the rotation provides a new V'.

Thank you for the support. Looking forward for an answer at the earliest.

One other solution is to identify the vector's endpoint with respect to the point P. Then, rotate the endpoint as desired and recompute the new vector based on the rotated endpoint and the point P.