- 7

- 0

Okay. First off. This isn't homework. I have been working on a personal project and if I could get an equation for this it would really help me out. I'll try and explain the problem the best I can.

What I need:

An equation/method where I can specify an angle theta and a 3D line and it returns the 3D coordinates of the points on the line which make the angle theta with the origin and the point (1, 0, 0).

The problem:

You have a 3D graph with origin O. The positional vector A with coordinates (1, 0, 0) and another position vector B. You could use the dot product function to work out the angle AOB, if you had B. But you don't.

Dot Product function:

cos(theta) = A.B/(|A|*|B|)

You also know that B is somewhere on the 3D line r = (x, y, z) + lambda(a, b, c), where lambda is proportional to the displacement from (x, y, z) and (a, b, c) is the 3D gradient. This line can also be represented as a Cartesian line equation in the form x=y=z (but some other co-efficients etc.) e.g it could be 2x=5-y=(3z-2)/4.

I want to specify an angle theta between BOA and work out position vector of A and the position vector of equation of the line B rests on. O will always have coordinates (0, 0, 0), but that doesn't mater as it's just a point of relevance.

Also, it i worth mentioning that there may well be two solutions for B for a given angle theta if the line cuts through the angle twice, or one or no solutions. Actually come to think of it it could have infinite solutions if theta was 90 degrees (Point 90 degrees from the vector (1, 0, 0) are on the plane x = 0, because this is a flat plane, as a pose to a cone shape (the one value of theta where this happens), if the x coordinate of every point line r is also always equal to 0, then there will be infinite solutions).

I like to think about the angle as a cone with the tip at the origin, (where every point on the surface of the cone is theta degrees away from the origin).

Ramblings of a mad man:

I have defined the function dotProduct (3DVector), which returns the angle AOB, when B is the parameter.

The only things that I could work out are that for very large values of lambda in the line r the coordinate tends towards being a multiple of (a, b, c) (3D gradient), as the (x, y, z part gets infinitely small by comparison). And so the coordnate (a, b, c) can be treated as B if lambda is infinitely large. So we can do dotProduct((a, b, c)), which returns the same angle as though B where (a, b, c).

Also I was thinking this:

If you take the line r2 = (0, 0, 0) + lambda*(a, b, c). As in a line with the same gradient as r, but goes through the origin. Then the point on the line r, which is perpendicular to the line r2 through the origin point, is the closet to the origin the line r will get and if we treat that point as B then theta will be within 90 degrees +- the acute angle a point on the line r2 makes with A and O. And since r2 goes through the origin, there are only two angles any point on the line r2 can make with A and O (on acute one when the point is less than 90 degrees and one obtuse one it is over 90 degrees).

The reason why I need this is because I have made a 3D engine, which takes into account perspective and that distortion effect you get when you take a panoramic photo with a large angle of view. To do the distortion effect I am just sampling the 3D line in 3D space very often and joining them with straight lines, but movement 3D space is only proportional to movement in the 2D rendering in very specific directions/positions relative to the camera. I have made it o it only samples as often as it need to (less when it is less distorted, more when it is more distorted etc.), but it would be a big help if I can figure out how to do this reverse dot product, because it will mean I can start rendering at the edge of a certain field of view, which will get rid of a lot of redundant computations.

Thanks for any help guys. I'd really appreciate.

Reagrds, Greg.

P.S. - If this is the wrong section, please say. [STRIKE]I will be happy to repost it elsewhere.[/STRIKE]

What I need:

An equation/method where I can specify an angle theta and a 3D line and it returns the 3D coordinates of the points on the line which make the angle theta with the origin and the point (1, 0, 0).

The problem:

You have a 3D graph with origin O. The positional vector A with coordinates (1, 0, 0) and another position vector B. You could use the dot product function to work out the angle AOB, if you had B. But you don't.

Dot Product function:

cos(theta) = A.B/(|A|*|B|)

You also know that B is somewhere on the 3D line r = (x, y, z) + lambda(a, b, c), where lambda is proportional to the displacement from (x, y, z) and (a, b, c) is the 3D gradient. This line can also be represented as a Cartesian line equation in the form x=y=z (but some other co-efficients etc.) e.g it could be 2x=5-y=(3z-2)/4.

I want to specify an angle theta between BOA and work out position vector of A and the position vector of equation of the line B rests on. O will always have coordinates (0, 0, 0), but that doesn't mater as it's just a point of relevance.

Also, it i worth mentioning that there may well be two solutions for B for a given angle theta if the line cuts through the angle twice, or one or no solutions. Actually come to think of it it could have infinite solutions if theta was 90 degrees (Point 90 degrees from the vector (1, 0, 0) are on the plane x = 0, because this is a flat plane, as a pose to a cone shape (the one value of theta where this happens), if the x coordinate of every point line r is also always equal to 0, then there will be infinite solutions).

I like to think about the angle as a cone with the tip at the origin, (where every point on the surface of the cone is theta degrees away from the origin).

Ramblings of a mad man:

I have defined the function dotProduct (3DVector), which returns the angle AOB, when B is the parameter.

The only things that I could work out are that for very large values of lambda in the line r the coordinate tends towards being a multiple of (a, b, c) (3D gradient), as the (x, y, z part gets infinitely small by comparison). And so the coordnate (a, b, c) can be treated as B if lambda is infinitely large. So we can do dotProduct((a, b, c)), which returns the same angle as though B where (a, b, c).

Also I was thinking this:

If you take the line r2 = (0, 0, 0) + lambda*(a, b, c). As in a line with the same gradient as r, but goes through the origin. Then the point on the line r, which is perpendicular to the line r2 through the origin point, is the closet to the origin the line r will get and if we treat that point as B then theta will be within 90 degrees +- the acute angle a point on the line r2 makes with A and O. And since r2 goes through the origin, there are only two angles any point on the line r2 can make with A and O (on acute one when the point is less than 90 degrees and one obtuse one it is over 90 degrees).

The reason why I need this is because I have made a 3D engine, which takes into account perspective and that distortion effect you get when you take a panoramic photo with a large angle of view. To do the distortion effect I am just sampling the 3D line in 3D space very often and joining them with straight lines, but movement 3D space is only proportional to movement in the 2D rendering in very specific directions/positions relative to the camera. I have made it o it only samples as often as it need to (less when it is less distorted, more when it is more distorted etc.), but it would be a big help if I can figure out how to do this reverse dot product, because it will mean I can start rendering at the edge of a certain field of view, which will get rid of a lot of redundant computations.

Thanks for any help guys. I'd really appreciate.

Reagrds, Greg.

P.S. - If this is the wrong section, please say. [STRIKE]I will be happy to repost it elsewhere.[/STRIKE]

**<< Mentor Note -- Use the Report button to ask the Mentors to move it >>**
Last edited by a moderator: