- #1

- 1,518

- 618

I can't figure out how to reverse it though, I should be able to take the resulting int, put it through a function with the height value and get back distance. Normally, when I get stuck, I just ask wolfram alpha to solve it for me, but that doesn't seem to be giving me an answer.intgetYPosition(floatheight,floatdist)const{

constfloathh = renderer -> viewPortHalfH / dist;

returnrenderer -> viewPortHalfH - hh + hh * ((height + renderer -> player -> verticalAngle * dist) / 128.0f);

}

floatgetDistYPosition(floatheight,intyPosition)const{

//wtf, I can't figure out what this should be

return1;

}

Is there something with my equation that makes it fundamentally irreversible?y = k - (k/d) + (k/d) * ((h + v * d) / 128) solve d

I feel like wolfram alpha is having trouble because the general equation has some quirks that the actual code won't? Like the fact that both renderer -> viewPortHalfH and dist are always positive and non-zero. How would I tell wolfram alpha about this (would it even help?)