title: 3d rotation around the origin
body: <p>I know there are plenty of questions about 3d rotation that have been answered here but all of them seem to deal with rotational matrices and quaternions in OpenGL (and I don't really care if I get gimbal lock). I need to get 3d coordinates EX:(x,y,z) of a point that always must be the same distance, I'll call it "d" for now, from the origin.  The only information I have as input is the deltax and deltay of the mouse across the screen. So far here is what I have tried:</p>
  
  <p>First:</p>
  
  <pre><code>thetaxz+=(omousex-mouseX)/( width ); 
  thetaxy+=(omousey-mouseY)/( height);
  </code></pre>
  
  <p>(thetaxy is the angle in radians on the x,y axis and thetaxz on the x,z axis)
  (I limit both angles so that if they are less than or equal to 0 they equal 2*PI)</p>
  
  <p>Second:</p>
  
  <pre><code>pointX=cos(thetaxz)*d;
  pointY=sin(thetaxy)*d;
  </code></pre>
  
  <p>(pointX is the point's x coordinate and pointY is the y)</p>
  
  <p>Third:</p>
  
  <pre><code>if(thetaxz)&lt;PI){
   pointZ=sqrt(sq(d)-sq(eyeX/d)-sq(eyeY/d));
  }else{
    pointZ=-sqrt(abs(sq(d)-sq(eyeX/d)-sq(eyeY/d)));
  }
  </code></pre>
  
  <p>(sq() is a function that squares and abs() is an absolute value function)
  (pointZ should be the point's z coordinate and it is except at crossing between the positive z hemisphere and negative z hemisphere.  As it approaches the edge the point gets stretched further than the distance that it is always supposed to be at in the x and y and seemingly randomly around 0.1-0.2 radians of thetaxz the z coordinate becomes NAN or undefined)</p>
  
  <p>I have thought about this for awhile, and truthfully I'm having difficulty warping my head around the concept of quaternions and rotational matrices however if you can show me how to use them to generate actual coordinates I would be glad to learn.  I would still prefer it if I could just use some trigonometry in a few axis. Thank you in advance for any help and if you need more information please just ask.</p>
  
  <p>Hint/last minute idea: I think it may have something to do with the z position affecting the x and y positions back but I am not sure.</p>
  
  <p>EDIT:  I drew a diagram:
  <img src="https://i.stack.imgur.com/9y2zM.png" alt="enter image description here"></p>