I am trying to model a robot arm (in 2D) that's supposed to have a camera at the end that moves with the arm. Given the field of view of the camera, I need to find whether a certain target is visible in this field of view as the endpoint of the arm starts moving. The horizontal of the camera is aligned with the last link of the robot arm, so the 'triangle' moves up and down, forwards and backwards etc. While this intuitively makes sense, I'm having trouble coming up with a formula for this. Also, as it's a camera field of view, the rays are technically infinitely long.
The data I have are: (example image below)
Cartesian coordinates of the last two 'points' of the robot arm (x3, y3) and (x4, y4)
Theta angle of the field of view
- Coordinates of the point of interest (this never changes)
Any suggestions?


Maybe something simple like this would work? Assume you have been able to compute your coordinates $P_3 = (x_3, y_3)$ and $P_4 = (x_4, y_4)$ and you know the position of the point you want to see with the camera $Q = (a, b)$. Form the vectors $\overrightarrow{P_3P_4} = (x_4 - x_3, \, y_4 - y_3)$ and $\overrightarrow{P_4Q} = (a - x_4, \, b - y_4)$. The dot product between the two vectors has the following meaning $$\Big(\, \overrightarrow{P_3P_4} \cdot \overrightarrow{P_4Q} \, \Big) = \|\overrightarrow{P_3P_4}\| \, \|\overrightarrow{P_4Q} \| \cos{\theta} = \|P_4 - P_3\|\, \|Q - P_4\| \cos{\theta}$$ where $\theta$ is the angle between the oriented line $P_4Q$ and the oriented horizontal of the camera, which is defined by the line $P_3P_4$. If $\theta \in \left(-\frac{\pi}{6}, \frac{\pi}{6}\right)$ then your object is visible. In terms of cosine of the angle, this translates into the condition $\cos{\theta} \in \left(\frac{\sqrt{3}}{2}, 1\right)$. If $\cos{\theta}$ is not in the interval $\left(\frac{\sqrt{3}}{2}, 1\right)$, then your point is not visible. Form the above formula \begin{align}\cos{\theta} &= \frac{\Big(\, \overrightarrow{P_3P_4} \cdot \overrightarrow{P_4Q} \, \Big)}{\|P_4 - P_3\|\, \|Q - P_4\| } = \frac{\Big(\, \overrightarrow{P_3P_4} \cdot \overrightarrow{P_4Q} \, \Big)}{\|P_4 - P_3\|\, \|Q - P_4\| } \end{align} so if we plug in the coordinates we obtain the expression
\begin{align} \cos{\theta} = f(x_3,y_3,x_4,y_4,a,b) = \frac{ (x_4 - x_3)(a- x_4) + (y_4 - y_3)(b- y_4)}{\sqrt{ (x_4 - x_3)^2 + (y_4 - y_3)^2} \,\,\, \sqrt{ (a- x_4)^2 + (b- y_4)^2}} \end{align}
If $\,\, f(x_3,y_3,x_4,y_4,a,b) \,\in \, \left(\frac{\sqrt{3}}{2}, 1\right) \,\, $ then the point with coordinates $(a,b)$ is visible. Otherwise, it is not.
Make sure I haven't made a mistake in the condition and the proper orientation of the angle. I have changed them three times already :)
Comment: Regarding the bounds of $\cos{\theta}$, I will try to explain this as follows.
The camera horizontal is the directed line $P_3P_4$, directed from $P_3$ to $P_4$. Since the directed line $P_4Q$, oriented from $P_4$ to $Q$, determines of the angle of the point $Q$ with respect to the camera horizontal $P_3P_4$, by definition the visibility occurs when the angle $\theta$ between $P_3P_4$ and $P_4Q$ (measured counterclockwise from $P_4Q$ to $P_3P_4$) changes from $-30^{\circ}$ to $30^{\circ}$. The cosine $\cos{\theta}$ is related to the orthogonal projection of $P_4Q$ onto the directed horizontal $P_3P_4$. Let us rotate $P_4Q$ around $P_4$ and see how $\theta$ changes. At first when $\theta = -30^{\circ}$ then $\cos{(-30^{\circ})} = \sqrt{3}/2$. As the direction $P_4Q$ gets more and more aligned with $P_3P_4$, the angle $\theta$ grows from $-30^{\circ}$ to $0$ and thus the cosine grows from $\sqrt{3}/2$ to $1$. After the alignment, when $\theta=0$ and $\cos{0} = 1$, the cosine $\cos{\theta}$ starts to decrease (while the angle $\theta$ keeps growing from $0$ to $30^{\circ}$) until the direction $P_4Q$ reaches $30^{\circ}$ with $P_3P_4$ and the cosine becomes $\cos{\theta} = \sqrt{3}/2$ again.