title: DXF Viewer: Calculate Extrusion Matrix for GDI+
body: <p>I'm currently working on a Viewer for DXF Drawings. I can already read the file (at least the most common tables and entities) and draw them. But I have one big issue I struggle to understand / implement.</p>
  
  <p>The most entities have an extrusion vector (which is, if I understood correctly, the normal of the surface I have to draw on)</p>
  
  <p>My problem is how I can calculate the matrix I have to apply to the Graphics object in my OnPaint method.</p>
  
  <p>Here an example of a LINE entitiy with a non-default extrusion:</p>
  
  <pre><code>  0
  LINE                   // Start of Entity
    5
  A08E5                  // Handle
  330
  70                     // Soft-Pointer ID
  100
  AcDbEntity             // Start of common entity data
    8
  Level 19               // Layername
    6
  Continuous             // Line type name
   62
       4                 // Color number (ARGB = 255, 0, 255, 255)
  370
      30                 // Line weight
  100
  AcDbLine               // Start of specific line entity data
   10
  208157.9494861194      // Start point X coordinate
   20
  206799.7837580488      // Start point Y coordinate
   30
  0.0                    // Start point Z coordinate
   11
  203237.9494861194      // End point X coordinate
   21
  206799.7837580488      // End point Y coordinate
   31
  0.0                    // End point Z coordinate
  210
  0.0                    // Extrusion direction X  (0==Default)
  220
  0.0                    // Extrusion direction Y  (0==Default)
  230
  -1.0                   // Extrusion direction Z  (1==Default)
  </code></pre>
  
  <p>I already know that the Extrusion in the given example multiplys the start and end X values with -1 but as the extrusion vector can point in any direction I need a proper conversion matrix for it.</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Thomas</p>