# Coordinates of line in sphere with x,y rotation

Lets say that I have a line with one end fixed to the center of a sphere, and the other end can freely rotate. If I were to rotate the line around the x and y axes, what would the coordinates be for the freely-rotating end?

Here's what I need this for:

I have a rectangle, and need to find the coordinates of each vertex when the rectangle is rotated (the rectangle will be rotated from its center at (0,0,0), and can have any width and height). I only need to rotate the rectangle around the x,y (or any pair really, but x,y are just a nice looking pair), because rotating the unincluded axis will be like rolling a pencil back and forth in your thumb.

I have found some helpful resources for questions similar to mine, but they don't solve my problem. For example, this here I've tried to understand, but I have minimal experience with matrices, and this doesn't exactly solve my problem.

2. You say we have a line with one end fixed at the origin; say that the point on this line which is distance 1 from the origin is $$v =(a,b,c).$$ When I rotate $$v$$ around the $$z$$ axis, I won't change it's $$z$$ coordinate--this will still be $$c.$$ If I rotate by an angle of $$\theta,$$ the output vector will be $$(cos(\theta)a - sin(\theta)b, sin(\theta)a + cos(\theta)b, c).$$
• If you would like to first rotate $(a,b,c)$ by an angle of $\theta$ around the $z$ axis and then rotate the result by an angle of $\alpha$ around the $x$ axis, the output would be $(a cos(\theta) - b sin(\theta), a sin(\theta) cos(\alpha) + b cos(\theta) cos(\alpha) - c sin(\alpha), a sin(\theta) sin(\alpha) + b cos(\theta) sin(\alpha) + c cos(\alpha).$ Commented Mar 2, 2019 at 1:20