Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was solving same problem few years back, when I was writing my diploma thesis. Here is a part of it which describes how to create camera for raytracing..</p> <p>First of all you need to define coordinate system of camera. It's orthonormal coordinate system, that means that all three basis vectors are perpendicular to each other and have same size (doesn't have to be "one"). Also you need to point out, if your coordinate system of camera is <a href="http://en.wikipedia.org/wiki/Cartesian_coordinate_system#Orientation_and_handedness" rel="noreferrer">right-handed or left-handed</a> (I will talk about left-handed). First you'll need to define <code>up vector</code> (the vector shows you what is y axis on your screen) and <code>camera direction vector</code> (so vector from eye position to middle of your projection plane). Then you'll calculate <code>left vector</code> (or right vector if you need) (which points where exactly is x axis on your screen) by <code>cross product</code> of the <code>up vector</code> and <code>camera direction vector</code>. Now, because only camera direction vector and left vector are perpendicular for sure, you have to make <code>one more cross product</code> of <code>camera direction vector</code> and <code>left vector</code> (vector y on the image).</p> <p>So you'll get camera coordination system like this one</p> <p><img src="https://i.stack.imgur.com/r3RNk.png" alt="left handed camera coordination system"></p> <p>No you have to define, how big is your projection screen in world coordinates. That might be sometimes tricky, so you can also define it by two angles <img src="https://i.stack.imgur.com/0rHlj.gif" alt="phi and theta angles"> (<code>phi</code> and <code>theta</code>) and distance from eye position (lets call it <code>d</code>). </p> <p>You'll get <img src="https://i.stack.imgur.com/qF2h6.gif" alt="u vector"> and <img src="https://i.stack.imgur.com/xppMa.gif" alt="v vector">. (the <code>x</code> vector is the vector which defines x axis on screen, so it's <code>left vector</code> or right vector, depends of handedness) By linear combination of those two vectors <code>u</code> and <code>v</code> you can compute any position on your projection screen. Coefficients <img src="https://i.stack.imgur.com/PvBz4.gif" alt="alpha"> <code>alpha</code> and <img src="https://i.stack.imgur.com/wSNoz.gif" alt="beta"> though represents distances <code>the point</code> from middle of projection screen. </p> <p>So <img src="https://i.stack.imgur.com/xIz2g.gif" alt="alpha coefficient"> and <img src="https://i.stack.imgur.com/sltg4.gif" alt="beta coefficient">, where <code>s</code> and <code>r</code> are <code>x</code> and <code>y</code> coordinates on your calculated image and <code>imageWidth</code> and <code>imageHeight</code> are appropriate sizes.</p> <p>So as you can see on this image</p> <p><img src="https://i.stack.imgur.com/XYnjT.png" alt="projection plane"></p> <p>Final position of any point on projection plane is <img src="https://i.stack.imgur.com/Ro3w4.gif" alt="point on projection plane">. </p> <p>Then calculation of requested vector is <img src="https://i.stack.imgur.com/Jtgv8.gif" alt="desired vector">.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload