JSFiddle - React, Tailwind, and code Playground
HTML
distanza: occhi <-> TV<input type="text" onkeyup="calc()"></input>cm
<div></div>
JavaScript
var ratioCm2Feet=2.54;
/*function calc1(form) {
a = form.a.value;
b = Math.round(Math.pow(Math.pow(a, 2)/1.31640624208984, .5)/2.97869411418791);
c = Math.round(Math.pow(Math.pow(a, 2)/1.31640624208984, .5)/4.46804291661112);
d = Math.round(Math.pow(Math.pow(a, 2)/1.31640624208984, .5)/6.70206437491669);
e = Math.round(Math.pow(Math.pow(a, 2)/1.31640624208984, .5)/13.9626341144098);
f = Math.round(Math.pow(Math.pow(a, 2)/1.31640624208984, .5)/27.9252682288196);
form.total1.value = b;
form.total2.value = c;
form.total3.value = d;
form.total4.value = e;
form.total5.value = f;
}*/
res={
'480p':2.97869411418791,
'720p':4.46804291661112,
'1080p':6.70206437491669,
'4k':13.9626341144098,
'8k':27.9252682288196
}
function diagonale2widescreenwidth(a){
return Math.pow(Math.pow(a,2)/1.31640624208984,.5)
}
feet2cm=30.48;
function calc(){
var cm=document.getElementsByTagName('input')[0].value*1,
div=document.getElementsByTagName('div')[0];
div.innerHTML='<b>Distance:</b><br>'+
'Feet '+(cm/(ratioCm2Feet*12)).toFixed(2)+'<br>'+
'Inches '+(cm/ratioCm2Feet).toFixed(2)+'<br>'+
'Meter '+(cm/100).toFixed(2)+'<br>'+
'<b>Best TV (16:9) Diagonale:</b><br>'+
(cm/ratioCm2Feet*.84).toFixed(0)+'" THX'+'<br>'+
//diagonale2widescreenwidth(cm/ratioCm2Feet*.84)+' inches<br>'+
//'Cm '+(cm*.84).toFixed(2)+'<br>';
'720p PPI: '+(Math.sqrt(Math.pow(1280,2)+Math.pow(720,2))/(cm/ratioCm2Feet*.84)).toFixed(0)+
' @ Optimal: '+Math.round(diagonale2widescreenwidth(cm/ratioCm2Feet*.84)/res['720p'])*feet2cm+'cm<br>'+
'4k PPI: '+(Math.sqrt(Math.pow(2*1920,2)+Math.pow(2*1080,2))/(cm/ratioCm2Feet*.84)).toFixed(0)+
' @ Optimal: '+Math.round(diagonale2widescreenwidth(cm/ratioCm2Feet*.84)/res['4k'])*feet2cm+'cm<br>'+
'1080p PPI: '+(Math.sqrt(Math.pow(1920,2)+Math.pow(1080,2))/(cm/ratioCm2Feet*.84)).toFixed(0)+
' @ Optimal:...