title: raytracing: problems with transformations
body: <p>I am having trouble incorporating transformations. For whatever reasons, everything is not going as I think it should, but to be honest - all the transformations back and forth make me quite dizzy. </p>
  
  <p>As I have read everywhere (although explicit explanations are rare, imho), the principle algorithm for transformations is as follows:</p>
  
  <ul>
  <li>transform the Ray (Origin and Direction) with the inverse of the transformation matrix</li>
  <li>transform the resulting Intersection-Point with the transformation matrix</li>
  <li>transform the object's normal at the Intersection-Point with the transposed of the inverse</li>
  </ul>
  
  <p>From what I understood, that should do the trick. I'm pretty sure that my problem lies when I try to calculate the lighting, since both the initial intersection and the lighting algorithm use the same function (<code>obj.getIntersection()</code>). But then again, I have no idea. :(</p>
  
  <p>You can read parts of my code here:</p>
  
  <p><a href="http://pastebin.com/uH8d7533" rel="nofollow noreferrer">main.cpp</a>, <a href="http://pastebin.com/ptXWwbTD" rel="nofollow noreferrer">scene.cpp</a>, <a href="http://pastebin.com/srWKfrVQ" rel="nofollow noreferrer">sphere.cpp</a>, <a href="http://pastebin.com/pywZR5En" rel="nofollow noreferrer">sdf-loader.cpp</a></p>
  
  <p>Please let me know if you need more info to help me - and please help me! ;)</p>
  
  <p>EDIT:</p>
  
  <p>I made some results, maybe someone "sees" (by the results) where I may be wrong:</p>
  
  <p>untransformed scene:</p>
  
  <p><img src="https://i.stack.imgur.com/d7fB6.jpg" alt="untransformed scene"></p>
  
  <p>sphere scaled (2,4,2):</p>
  
  <p><img src="https://i.stack.imgur.com/tTcI0.jpg" alt="sphere scaled (2,4,2)"></p>
  
  <p>box translated (0,-200,0):</p>
  
  <p><img src="https://i.stack.imgur.com/wJaJy.jpg" alt="box translated (0,-200,0)"></p>
  
  <p>sphere translated (-300,0,0):</p>
  
  <p><img src="https://i.stack.imgur.com/vA0X5.jpg" alt="sphere translated (-300,0,0)"></p>
  
  <p>sphere x-rotated (45°):</p>
  
  <p><img src="https://i.stack.imgur.com/uufLX.jpg" alt="sphere x-rotated (45°)"></p>