The reverse operation for the dot product?

cawthorne

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]
<< Mentor Note -- Use the Report button to ask the Mentors to move it >>

Last edited by a moderator:

mfb

Mentor
For each lambda, you have a known point r. You can calculate the angle α you get with that value of lambda, and solve the resulting equation (with the fixed angle) for lambda.
You will get some special cases during the solution process, which correspond to "all lambdas are a solution" and similar things.

cawthorne

For each lambda, you have a known point r. You can calculate the angle α you get with that value of lambda, and solve the resulting equation (with the fixed angle) for lambda.
You will get some special cases during the solution process, which correspond to "all lambdas are a solution" and similar things.
r = (x, y, z)+ lambda*(a, b, c)

where x, y, z, a, b, c are know and lambda is known.

let's say we want r when alpha = 80 degrees

Okay so we have the equation alpha = acos(((x+ lambda*a, y + lambda*b, z + lambda*c).(1, 0, 0))/(((x+ lambda*a)^2 + (y+ lambda*b)^2 + (z + lambda*c)^2)^(0.5))*(1^2 + 0^2 + 0^2)^0.5))

(1^2 + 0^2 + 0^2)^0.5) = 1, so alpha = acos(((x+ lambda*a, y + lambda*b, z + lambda*c).(1, 0, 0))/(((x+ lambda*a)^2 + (y+ lambda*b)^2 + (z + lambda*c)^2)^(0.5)))

since wee're using (1, 0 , 0), we only need to consider the x component of r for the dot product, so alpha = acos((x+ lambda*a)/(((x+ lambda*a)^2 + (y+ lambda*b)^2 + (z + lambda*c)^2)^(0.5)))

Then I try to rearrange and get stuck

cos^2(alpha) = (x^2 + 2*lambda*x*a + (lambda*a)^2)/((x+ lambda*a)^2 + (y+ lambda*b)^2 + (z + lambda*c)^2)

If you can rearrange that for lambda I would be very grateful! My maths skills don't seem to be up to it :).

Last edited:

dodo

Hi, cawthorne,
you are doing fine so far. You expanded the square in the numerator of the fraction, and eventually you will have to expand also the three squares in the denominator. This could be done now, or a bit later.

The important next step is to notice that cos^2(alpha) is just a constant, because alpha is given. You can pass the whole denominator multiplying to the left side. Then distribute the constant cos^2(alpha), and then expand the squares as you did before.

Finally you will be able to group the terms in lambda^2, in lambda and with no lambda, to find a solution of a quadratic equation. (You will see when you get there.)

cawthorne

Ahhh silly me :P. I did think it might have been a quadratic thing, but I got lost in all the extra terms (which I knew already!) :P.

Thanks!

cawthorne

Ahhh silly me :P. I did think it might have been a quadratic thing, but I got lost in all the extra terms (which I knew already!) :P.

Thanks!
By "I knew already" I meant that the extra terms where the input variables (constants for each given 3D vector), so I was silly to have been confused by them :P. Sometimes it's the easy parts which get you :P.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving