3d calculus, I probably could never sit through a course of that

(even though I probably really need it)

Well for starters, I'm using OpenGL so everything is computed through matrices. The world has one matrix, and the objects have a matrix so there are matrices in matrices.

Though what I'm doing is just getting the angles of things and letting OpenGL display it in a matrix (I say where to put it, OpenGL puts it there). I'm using a function (gluUnProject) that gets the 2D coordinates of the mouses position and reverses the main matrix to get its position as a 3D vector. I can define on how far back I want to "unproject" the mouses position (I can define a mouses depth). So I unproject the mouse twice, once close to the camera, once far from the camera (NOTE: OpenGL computes the angles of the screen, so when I say depth I do not mean the worlds z coordinates, I mean its the depth relevant to the area that the screen is viewing). Then I get the angle from those two points (as I have solved with Raxx's help above).

Now what I'm doing with this angle is...

I have a for loop (a type of loop in computer programming for those who do not know), that goes through for a number of times (which is the "life" of the ray), and moves a certain distance (which I can define as any amount I want, for now its just moving a distance of one tenth (0.1)).

So I'm trying to figure out how to use sine and cosine to compute the yaw and pitch of the ray and the distance to move by and put in a 3D vector coordinate (so compute yaw and pitch, to get the amount of x y and z to move by).

There are multiple ways to make rays, I want to implement at least these two ways...

The way I have above

and an intersecting point, which contains two points, and finds the intersection of objects and whatever in the line formed by those two points.

The reasons why I want the one above, is because then you could cast the ray to infinite space (for as long as the application is running you could have the ray moving). The reason why I want the other way, is to have accurate and quick results.

Also I'm planing to combine the two ways, cast a ray that moves a distance then checks if there was an intersection between that position of the ray and the last. So I could have the infinite ray and accurate results together. Basically I'm making it so that you could use rays to the max.