Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to figure out this problem for game development. I don't have that great of mathematics education and stumped for a formula for this. Please fix my tags if they don't make sense.

I know that I need an entity to be 60 units wide at 8,000 distance.

I also know that I need an entity to be 350 units wide at 970 distance.

What formula should I use to calculate the width of the entity given any distance?

share|cite|improve this question
up vote 3 down vote accepted

Assuming that you want a linear fit, suppose you want width at distance x to be ax + b. Then 800a + b = 60, and 970a + b = 350.

You can solve this to get width at distance x to be $60 + \frac{290 \times 8000}{7030} - \frac{290}{7030}x$ which is roughly $390.014225 - 0.0412517781x$. This will make your entity disappear at about 9454 distance, but from the question it looks like its distance will not exceed 8000 units hopefully.

share|cite|improve this answer
Thank you, this is exactly what I needed. I'm assuming if I say it needs to be 400 wide at 970, I can just add 50 to both 290 in the equation? – Cow King Apr 18 '12 at 7:49
If you want it to be a1 wide at b1 and a2 wide at b2, the formula is $a1 + \frac{(a2-a1)*b1}{b1-b2} - \frac{a2-a1}{b1-b2}x$. You can plug in the values as you want. – Wonder Apr 18 '12 at 7:55

This 350 does not compute. If an object appears 60 wide at 8000 distance, then at 970 distance, it is about 8.25 times closer, and should be that many times bigger: 60 x 8.25 = 495.

(If this is not about perspective, then what?)

share|cite|improve this answer
This is probably correct, the two data points I gave were just eye balling it. I'm going to have to tweak the values later on and make it accurate like you pointed out. I'm overlaying targeting reticules in a 2D space after projecting them into the 3D world. – Cow King Apr 18 '12 at 7:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.