title: Calculating position of a item relative to camera
body: <p>I'm making a 3D-game using C++ and Irrlicht. It is a FPS-style game, so player should be able to carry weapons. But I've been struggling with calculating the position relative to the camera. If camera wouldn't rotate, calculation would be easy:</p>
  
  <pre><code>// node is camera's child
  vector3df modifier = vector3df(2, 0, 2);
  node-&gt;setPosition(node-&gt;getPosition() + modifier);
  </code></pre>
  
  <p>But however, camera isn't a static but a rotating object, so things are a bit more complicated. Here's an image which hopefully crearifies what I'm trying to say:</p>
  
  <p><img src="https://i.stack.imgur.com/r3nmq.png" alt="A picture tells more than a thousand words"></p>
  
  <p>This should work in all dimensions, X, Y and Z. I think there's only two trigonometric functions for this kind of purpose, sine and cosine, which are for calculating X and Y coordinates. Am I at the wrong path or can they be applied to this? Or is there a solution in Irrlicht itself? There's the code which I've tried to use (found it from SO):</p>
  
  <pre><code>vector3df obj = vector3df(2, 0, 2);
  vector3df n = vector3df(0, 0, 0);
  n.X = obj.X * cos(60 * DEGTORAD) - obj.Z * sin(60 * DEGTORAD);
  n.Z = obj.Z * cos(60 * DEGTORAD) + obj.X * sin(60 * DEGTORAD);
  node-&gt;setPosition(node-&gt;getPosition() + n);
  </code></pre>
  
  <p>But the weapon just flies forward.</p>
  
  <p>I would be glad for any kind of help or guidance.</p>
  
  <p>P.S. Hopefully this question is clearer than the previous one</p>