I am reading XY values from a joystick, such as this one.
The joystick provides 0 to 1023 values in both x and y directions, but I have scaled the range to be between -512 and 512, thus, the center location is at 0, 0. This allows me to get the correct angle ($\theta$). My joystick has a pole attached to it and looks similar to a flight stick. I am trying to find the XYZ location of the tip of this stick with respect to the origin of the joystick given the joystick XY coordinates and the length of the stick.
Given the sensor XY coordinates and considering the spherical coordinate system, I can calculate the theta using the formula $\theta = atan2(y, x)$. I know the pole length L, but I don't know and don't know how to find the $\phi$:
I considered achieving this either through geometry calculations, or through coordinate transformation, but I am not sure which angles to use to achieve such transformation.
Thus, I got stuck and ask you for any advice/guidance on how to find the XYZ location of the tip of this stick with respect to the origin of the joystick given the joystick XY coordinates and the length of the stick.
Sorry for the links to images - my reputation is too low to upload them.
Edit: I forgot to mention that I can also calculate the magnitude using the joystick X and Y coordinates $mag = \sqrt{x^2 + y^2}$, but I am not sure how to use it in this context.