I don't really know how to formulate the title, but the problem is the following:
I'm using a scripting language called "SQF" which has been created by a company named "Bohemia Interactive" (no, I do not work for them) and it's for modding their games. So I won't fill up these lines with code. If somebody else knows it and wants to see, comment and I'll add what I've tried so far.
The issue anyway is rather abstract, so I'm going to explain it with an archer and his target. Ratios may not be correct as they are only for explanation.
Say I (as the player) am the archer (first person), the target is 10m away, has a diameter of 2m and appears 200px in diameter on the screen. Now I aim 50px left of the target edge, execute my desired function and and get the info that this is 1m away from the target (2m from its center).
Now, I move 90m back, so the target is 100m away and appears 100px in diameter (don't know if that's correct, but you get the idea). Now I am aiming 25px left of the target and again, execute my desired function and it should tell me again that the distance is 1m.
Now, the "real" distance was 1m in both cases, but on my screen it was 50px at the first aim and 25px at the second.
So, what I am looking for is a (mathematical/programmatical) model to get the "real" distance between the target and where I aimed, no matter how far away I was from the target. I do have the positions of both archer and target in 3D coordinates. Though SQF is a very special language, it does provides a function to calculate the distance in meters and to dertermine certain geometrical values:
... so there's no need for that.
I know, this is very abstract, but I am hoping, somebody could give a hint or knows a mathematical procedure to do that.
If somebody knows how to do it in C, C++ or Java, I can write these languages, so that would be great!