title: C++ Advanced 3D coordinates to 2D Coordinates
body: <p>My question: How to convert a 3D coordinate on a 2D screen?
  I red a lot about that but all my research just showed half answered or even unanswered replies, some were wrong (tested them) so I ask again and try to add as much detail as possible.
  Here are the structures we will work with:</p>
  
  <pre><code>struct COORD3D
  {
      int X;
      int Y;
      int Z;
  };
  struct PAN3D//Rotate around these axis
  {
      float X;
      float Y;
      float Z;
  };
      struct COLOR
  {
      Uint8 R;//RED
      Uint8 G;//GREEN
      Uint8 B;//BLUE
      Uint8 A;//ALPHA
  };
  struct CAMERA
  {
      COORD3D Pos;
      PAN3D   Rot;
      float   angle;
      int RESX;//X Resolution
      int RESY;//Y Resolution
  };
  struct POI
  {
      COORD3D Pos;
      COLOR   Col;
  };
  struct OBJECT
  {
      COORD3D Pos;//absolute position
      list&lt;POI&gt; dots;//relative to object position
      list&lt;pair&lt;POI*, POI*&gt;&gt; lines;//Pointers to the dots to connect them
      PAN3D Rot;//absolute rotation
  };
  </code></pre>
  
  <p>Now what I need is a function that looks like:</p>
  
  <p>POI Convert3dTo2d(CAMERA cam, POI point);</p>
  
  <p>(must be a "POI" because of the color ;) )
  I already got an alogythm that goes through all objects and all of their points
  And the fact that there is a camera tells you that it's not an orthograhic voew but a perspective.</p>
  
  <p>Please comment the code you write here ropperly so everyone can understand it.
  If you got no clue of how to do this or just got approaches or non direct solutions, please don't answer, that doesn't really help us.
  <a href="http://sta.sh/0de60ynp9id" rel="nofollow">http://sta.sh/0de60ynp9id</a> &lt;- This image should describe it a bit</p>
  
  <p>Os (Windows 7), Microsoft Visual Studio 2013(I'm just using the c++ part of it)
  I Build it for x64 (if it is important ;) )
  But I don't think that is important for a little bit mathematic algorythms</p>
  
  <p>If you got any questions, feel free to ask me</p>
  
  <p>Okay, I think I got a new( to me new) way to do this, gonna try it tomorrow and will tell you if it work's (that's the part that everyone forgets but I try not to forget it)</p>