-
Ray Tracer Equations
Given:
eye is at (x,y,z)
SphereA is at (Sx,Sy,Sz)
Radius = 3
Screen is set up as shown:
(TopLeft) (WidthVector)
0------------------------------------>
|
|
|(HeightVector)
|
|
|
V
TopLeft is (Cx,Cy,Cz)
WidthVector is [Wx,Wy,Wz]
heightVector is [Hx,Hy,Hz]
For each Pixel on the screen is an ordered pair (w,v)
where w numbers each horizontal pixel
and v numbers the verticle ones.
Show me an equation for the shortest distance to the sphere
for a ray coming from the eye through the
correlating spot on the view plane for every pixel.
If there is no intersection this should result in division by zero.
Good Luck
-
Come on!
Is nobody interested??
Surely this cant be too difficult. i did this in QBASIC as a Freshman in highschool.
-
The first step is to find the point on the view plane that corresponds to the ordered pair (w,v)
this is easy:
(assuming 800 by 600 screen rez.)
ViewX = TopLeft.x + (WidthVector.x * w/800) + (HeightVector.x * v/600)
ViewY = TopLeft.y + (WidthVector.y * w/800) + (HeightVector.y * v/600)
ViewZ = TopLeft.z + (WidthVector.z * w/800) + (HeightVector.z * v/600)
The point is (ViewX, ViewY, ViewZ)