1

我正在通过jscalc.io制作一个超级基本的 JS 计算器

我的变量有问题。这是我的计算器的链接

问题只是右下角的“GSD”输出。我没有收到任何语法错误,但 GSD 不会吐出数字……它只是空白?是因为我试图使用输出而不是输入来创建函数吗?

希望有人可以给予任何指导。

这是我的 GSD 输出变量公式的相关代码:

'use strict';
var meters = inputs.W * inputs.L
;var kilometers = meters * 0.000001
;var acres = meters * 0.000247105
;var hectares = meters * 0.0001
;var miles = acres * 0.0015625
;var H = H
;var GSD = (Sw * H * 100) / (Fr * imW);

//GSD = (Sw * H * 100) / (Fr * imW)

// DRONE CAMERA TYPE SETTINGS RESOLUTION
console.log(inputs.camera);
var imW;
if (inputs.camera.toString() === 'P3I1'){
imW = 4000;
}
console.log(inputs.camera);
var imH;
if (inputs.camera.toString() === 'P3I1'){
imH = 3000;
}
console.log(inputs.camera);
var imW;
if (inputs.camera.toString() === 'I1P'){
imW = 4608;
}
console.log(inputs.camera);
var imH;
if (inputs.camera.toString() === 'I1P'){
imH = 3456;
}
console.log(inputs.camera);
var imW;
if (inputs.camera.toString() === 'CS100'){
imW = 4000;
}
console.log(inputs.camera);
var imH;
if (inputs.camera.toString() === 'CS100'){
imH = 3000;
}

// DRONE CAMERA TYPE SETTINGS FOCAL LENGTH
console.log(inputs.camera);
var Fr;
if (inputs.camera.toString() === 'P3I1'){
Fr = 3.61;
}
console.log(inputs.camera);
var Fr;
if (inputs.camera.toString() === 'I1P'){
Fr = 15;
}
console.log(inputs.camera);
var Fr;
if (inputs.camera.toString() === 'CS100'){
Fr = 5.2;
}

// DRONE CAMERA TYPE SETTINGS PIXEL PITCH
console.log(inputs.camera);
var PP;
if (inputs.camera.toString() === 'P3I1'){
PP = 1.56;
}
console.log(inputs.camera);
var PP;
if (inputs.camera.toString() === 'I1P'){
PP = 4.8;
}
console.log(inputs.camera);
var PP;
if (inputs.camera.toString() === 'CS100'){
PP = 3.4;
}

// DRONE CAMERA TYPE SETTINGS SENSOR WIDTH
console.log(inputs.camera);
var Sw;
if (inputs.camera.toString() === 'P3I1'){
Sw = 6.24;
}
console.log(inputs.camera);
var Sw;
if (inputs.camera.toString() === 'I1P'){
Sw = 22.12;
}
console.log(inputs.camera);
var Sw;
if (inputs.camera.toString() === 'CS100'){
Sw = 13.6;
}

return {
  meters: meters,
  kilometers: kilometers,
  acres: acres,
  hectares: hectares,
  miles: miles,
  imW: imW,
  imH: imH,
  Fr: Fr,
  PP: PP,
  Sw: Sw,
  GSD: GSD,
  // imH: imH
};

感谢您的关注!

4

1 回答 1

1

问题出在这条线上var H = H,这应该是var H = inputs.H

于 2017-02-10T21:09:16.600 回答