# Raytracer code help

2 replies to this topic

### #1stromhau

New Member

• Members
• 7 posts

Posted 18 October 2004 - 03:57 PM

Hi.

Could anyone please explain the variable fl for me in this link
http://graphics.csail.mit.edu/classes/6.83...19/Slide27.html ?

This line
float fl = (float)(width / (2*Math.tan((0.5*fov)*Math.PI/180)));

What does these line do ?

Vp = Vector3D.normalize(look);
Vp.x = Vp.x*fl - 0.5f*(width*Du.x + height*Dv.x);
Vp.y = Vp.y*fl - 0.5f*(width*Du.y + height*Dv.y);
Vp.z = Vp.z*fl - 0.5f*(width*Du.z + height*Dv.z);

Thanx

### #2z80

Valued Member

• Members
• 104 posts

Posted 18 October 2004 - 04:14 PM

Looks like fl is the distance to the projection plane.

The 3 last lines computes the green vector.

I think so at least..

EDIT: Looks like setup for shooting rays thru the projection plane into the scene using the end of the green vector as starting point and du and dv as stepping delta values on the projection plane.

fl is computed based on field of view (fov) and the width in pixels of the final image.

### #3anubis

Senior Member

• Members
• 2225 posts

Posted 19 October 2004 - 06:42 PM

fl is the distance to the projection plane. if you think of the image as a small window in the world moving the eye position away from the plane narrows down the field of view and moving it closer broadesn it. imagine (in 2d) a triangle that the eye forms with the image plane. you know the field of view and you know the width of the image (usually you will choose a width of one here to make computations easier and use 1 / width and 1 / height steps in this one by one window). this can easily be done using trigonometric relations. here : tan(angle) = adjacent / opposite or adjacent = opposite * tan(alpha) where adjacent is the distance to the projection plane
If Prolog is the answer, what is the question ?

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users