Math Q: Detecting if telescope is pointed at star/signal

(This is more of a math question than blueprints, though eventually I plan to translate it to BP)

I’ve been toying with the idea of a game where the player aims an observatory telescope at different regions of sky and attempts to detect ‘signals’ from intelligent life (think SETI). They would have control over both vertical and horizontal rotation of their telescope When the player engages a survey, I need to return a yes/no response of whether or not a signal is found in the direction the telescope is pointed.

I imagine the location of the signal(s) the player is searching for would be just stored as a vector(rather than an actual actor in the scene). So lets assume the coordinate of the player’s telescope is 0,0,0 and the location of the signal they are searching for is an arbitrary point in 3D space like 370,-80,104.

I apologize if this is a big ask, but what would the math look like to test if the angle of the telescope, with a predetermined field of view angle, is encompassing my hidden signal location?

Dot product is the thing you are looking for. It equals to 1 (looking directly at the object) to 0 (the object is at 90 degrees to your view). UE4 has an example of this in the math level.

To expand this, you get the angle between the direction of your telescope (u) and the vector of your signal (v) with
angle = arccos( norm(u) * norm(v) )
where norm(x) means the normalized vector of x and * means the dot product. So if the resulting angle <= your view angle you’re detecting the signal, otherwise not.

Thanks guys =) Regrettably I wasn’t a good math student in my high school days, but you’ve given me a very good place to start studying.

You can also convert signal position to screen space and compare how far from screen’s center it is.