# finding rotation matrix in 3d

suppose I have a normalized vector perpendicular to a plane like

$x = \frac{(2i+3j+k)}{\sqrt{14}}$ , how can I find a rotation matrix A, such that it rotates x into the xy plane like so:

$Ax = y = \frac{(i, j)} {\sqrt{2}}$

edit retag close merge delete

why did you rotate the vector around z axis? can't we rotate it around x and y axes instead?

Your original question doesn't have a unique answer. There are infinitely many rotations that take your vector x to a vector in the XY-plane.

Sort by » oldest newest most voted

According to documentation matrix.ith_to_zero_rotation return a rotation matrix that sends the i-th coordinates of the vector v to zero by doing a rotation with the (i-1)-th coordinate :

sage: v = vector((2,3,1))/sqrt(14)
sage: matrix.ith_to_zero_rotation(v, 2)
[                       1                        0                        0]
[                       0  3/10*sqrt(14)*sqrt(5/7)  1/10*sqrt(14)*sqrt(5/7)]
[                       0 -1/10*sqrt(14)*sqrt(5/7)  3/10*sqrt(14)*sqrt(5/7)]
sage: matrix.ith_to_zero_rotation(v, 2) * v
(1/7*sqrt(14), sqrt(5/7), 0)


See also matrix.vector_on_axis_rotation.

more