Take the 2-minute tour ×

I have an equation which I use to get the height of an object based on the distance that object is from a viewpoint. The problem is that it slopes down too quickly. $$ \text{visibleHeight} = k \cdot \frac{\text{actualHeight} }{ \text{distance}} $$ The value of $k$ is the height I want per actual meter when the object is 1 meter away. So, if the object is 1 meter away and the actualHeight is 2 meters and I specify $k$ as 7 pixels then that means the visibleHeight will be 14 pixels.

So, I control the height of the object at 1 meter away, but I don't control the rate at which the height drops off as it gets farther away. I want to rotate the equation around $\text{distance}=1$ such that the visibleHeight has a particular value when distance is (for example) 20 meters away.

My first try is to reformulate the equation as this: $$ H(d \geq 1) = \frac{k \cdot h}{d} + M(d) $$ $H(d)$ is the overall function which takes $d$ as the input ($d$ will never be less than 1). The $M(d)$ function must be defined such that $M(1)=0$ and $M(n)=p$ where $p$ is the extra height that I want at distance $n$.

I'd probably obvious, but I'm not sure what $M(d)$ needs to be in order to achieve this.

The overall rate of decrease should follow the original path. I just want to grab the line and tilt it up a bit with the axis of rotation at $d=1$.

share|improve this question
add comment

1 Answer 1

If you know the visibleHeight at 1 meter, your original equation gives what it should be at 20 meters. It is just visibleHeight (1 meter)/20. If you do anything else, the perspective will not be right.

If you don't want the image shrinking this fast, maybe you could make a table like the following: $$\begin {array}{c|c|c}\text{Distance}&\text{Pixels from equation}&\text{Pixels desired} \\ \hline 1&14&14\\2&7&10\\7&2&4\\14&1&2\end{array}$$

Then some transform can be designed to do that.

share|improve this answer
add comment

Your Answer


