1

How would I go about solving this equation for $ \alpha $?

$$ \tan (\alpha + \Theta _1) - \tan (\alpha + \Theta _0) = \tan (\alpha + \Theta _0) - \tan (\alpha + \Theta _2) $$

Is there a way to calculate $\alpha$ directly or do I have to iterate?

$\alpha$ is always between $0$ and $\pi / 2$

Here is an abstract version of what those angles are enter image description here

In case someone tumbles upon this: Check the answer of Barry Cipra. An alternative is to just brute force it the way I did and use the angle addition theorem like suggested in the comments. My solution was $$ \tan(\Theta_0) = c_0 $$ $$ \tan(\Theta_1) = c_1 $$ $$ \tan(\Theta_2) = c_2 $$ $$ \alpha = \arctan\left(2c_0 -c_1 - c_2 \over c_0c_2+c_1c_0 - 2c_1c_2\right) $$

which gives back the same result.

GRASBOCK
  • 123
  • You could use trignometric identities but the question lacks context in its current form. What are $\Theta_i$? – an4s Mar 27 '20 at 16:31
  • @an4s I have added a Picture. It will later be used to get the angle at which I am looking at a surface. The thetas are directed towards fixed calibration points. – GRASBOCK Mar 27 '20 at 16:49
  • Are $\Theta_i$ fixed? Do you know what the total sum of all angles (i.e., $\alpha + \Theta_1$) is? – an4s Mar 27 '20 at 16:51
  • Maybe use the $\tan(A+B)$ formula in every term to get a quadratic in $\tan\alpha$? – Vishu Mar 27 '20 at 17:06
  • @an4s The Angles are fixed for each calibration. So they do change once changing the position of the camera and recalibrating. – GRASBOCK Mar 27 '20 at 17:27

1 Answers1

2

Let $x=\tan(\alpha+\Theta_0)$ and $T_i=\tan(\Theta_i-\Theta_0)$ for $i=1$ and $2$. Using the angle addition formula for the tangent function, we can rewrite the equation as

$${x+T_1\over1-xT_1}+{x+T_2\over1-xT_2}=2x$$

Clearing out denominators gives

$$(x+T_1)(1-xT_2)+(x+T_2)(1-xT_1)=2x(1-xT_1)(1-xT_2)$$

which expands to

$$(T_1+(1-T_1T_2)x-T_2x^2)+(T_2+(1-T_1T_2)x-T_1x^2)=2T_1T_2x^3-2(T_1+T_2)x^2+2x$$

and reduces to the cubic

$$2T_1T_2x^3-(T_1+T_2)x^2+2T_1T_2x-(T_1+T_2)=0$$

which factors as

$$(2T_1T_2x-T_1-T_2)(x^2+1)=0$$

The sole real root is

$$x={T_1+T_2\over2T_1T_2}$$

so up to an adjustment by $\pi$, we have

$$\alpha=\arctan\left(T_1+T_2\over2T_1T_2\right)-\Theta_0$$

Note, without some additional assumptions on the $\Theta_i$'s, we can only guarantee $|\alpha|\le\pi/2$, not $0\lt\alpha\lt\pi/2$

Added later (at OP's request): It takes a couple of steps to turn the equation

$$\tan(\alpha+\Theta_1)-\tan(\alpha+\Theta_0)=\tan(\alpha+\Theta_0)-\tan(\alpha+\Theta_2)$$

into the equation in $x$ and $T_i$s at the top of the answer. The first step is to move the subtracted tan's from one side to the other to get

$$\tan(\alpha+\Theta_1)+\tan(\alpha+\Theta_2)=2\tan(\alpha+\Theta_0)$$

The right hand side is now simply $2x$ when we let $x=\tan(\alpha+\Theta_0)$. The next trick is to note that $(\alpha+\Theta_i)=(\alpha+\Theta_0)+(\Theta_i-\Theta_0)$, and therefore

$$\tan(\alpha+\Theta_i)={\tan(\alpha+\Theta_0)+\tan(\Theta_i-\Theta_0)\over1-\tan(\alpha+\Theta_0)\tan(\Theta_i-\Theta_0)}={x+T_i\over1-xT_i}$$

when we let $T_i=\tan(\Theta_i-\Theta_0)$.

Remark: My initial impulse was to use the slightly simpler-looking substitutions $x=\tan\alpha$ and $T_i=\tan\Theta_i$, which turns the equation $\tan(\alpha+\Theta_1)+\tan(\alpha+\Theta_2)=2\tan(\alpha+\Theta_0)$ into

$${x+T_1\over1-xT_1}+{x+T_2\over1-xT_2}=2{x+T_0\over1-xT_0}$$

This also leads to a cubic after clearing out denominators, but there are three denominators to clear out, which means there's a lot of algebra to do. Being both lazy and error-prone, I discarded all that scratch work and started over with the substitution $x=\tan(\alpha-\Theta_0)$, which simplified the algebra and led to a nice result.

Barry Cipra
  • 79,832
  • Wow. did you do that yourself or do you have some kind of magic calculator? The factoring out really helped me with my solution (I was following the advice in the comments), because otherwise I would have to solve a 3 degree polynomial (I didn't see the similarity). Very clever. However I don't know how you go from my equation to those $T_i$ – GRASBOCK Mar 27 '20 at 18:53
  • @RIJIK, do you want me to elaborate on the steps I took in getting from your equation to the first displayed equation in my answer? – Barry Cipra Mar 27 '20 at 19:38
  • If it's not a lot of work, that would be great. Otherwise just point out the main steps. I might be able to figure it out on my own from there. – GRASBOCK Mar 28 '20 at 00:32