Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi I am wondering how best to explain this, I am working with WebGL (effectively OpenGL) and I have the ray cast from clicking in 3d space. I have the far and near values of the ray cast, the camera position and the target it is looking at.

How do I work out where the ray cast starts and ends, effectively to draw a line to show the ray cast through 3d space. The most confusing part of this for me is the angles, subtracting the angles of the cameras face which are also in radians.

Camera position would obviously be the start point, so I need to use that and using the direction the camera is facing, along with the near and far values of the ray to get the end point! I'm confused, please help.

share|cite|improve this question
How are the angles that the camera is facing given? Then are the near and far values the distance from the camera? Do you have the camera location in 3D space, or is it take to be the origin? – Ross Millikan Dec 30 '10 at 15:40
up vote 0 down vote accepted

Solved: I obtained the correct values from else where within the WebGL wrapper.

share|cite|improve this answer
Please accept your answer so the robot doesn't keep bringing this up. To do so, check the gray check mark. Thanks – Ross Millikan Dec 30 '10 at 19:23
sorry it said I had to wait a long time to accept my own answer, I ended up forgetting about the post. – Chris Jan 10 '11 at 2:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.