I need help swapping math variables

I need help swapping a variable in this equation.

local dist = width/(2*math.tan(math.rad(FOV/2)))

So what this does is it calculates the distance needed for the dolly zoom effect with the cameras field of view being inputted. However, I want to input the distance instead of the FOV. So like how would I get it to give me the required FOV instead?

“idk man” -my dad 5 minutes ago

You can calculate the required FOV for a given distance and width using the inverse tangent function (atan). The formula would be:
FOV = 2 * atan(width / (2 * distance))

local FOV = 2 * math.deg(math.atan(width / (2 * dist)))

For example.

4 Likes

HOLY CRAP thank you so much now I can zoom in on things cooly

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.