Skip to content

Instantly share code, notes, and snippets.

@n1ckfg
Created February 2, 2018 21:35
Show Gist options
  • Save n1ckfg/12783f64f84ef2bb326ff88ae4b1f6c1 to your computer and use it in GitHub Desktop.
Save n1ckfg/12783f64f84ef2bb326ff88ae4b1f6c1 to your computer and use it in GitHub Desktop.
float getVFov(float hFov, float w, float h) {
float hFovRad = hFov * PI / 180;
float vFovRad = 2 * atan(tan(hFovRad/2) * h/w);
return ceil(vFovRad * 180 / PI);
}
void setup() {
println("horizontal FOV 90 -> " + getVFov(90, 16, 9) + " vertical FOV (16:9)");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment