Created
July 25, 2018 01:46
-
-
Save mamadcloud/95c8fe8f5816286f2ad62c81f937e6b6 to your computer and use it in GitHub Desktop.
Body Composition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BodyComposition { | |
height = 0.0; | |
weight = 0.0; | |
age = 0; | |
sex = 0; // 0 female; 1 male; | |
twoLegs = 0; | |
bodyFatPercentage = 0.0; | |
errorMeasurement = 0; | |
_qword_1c08 = 9.058; | |
_qword_1c10 = 100.0; | |
_qword_1c20 = 0.32; | |
_qword_1c18 = 12.226; | |
_qword_1c28 = 0.0068; | |
_qword_1c30 = 0.0542; | |
_qword_1c38 = 0.5; | |
_qword_1c40 = 90.0; | |
_qword_1c48 = 220.0; | |
_qword_1c50 = 10.0; | |
_qword_1c58 = 200.0; | |
_qword_1c60 = 1200.0; | |
_qword_1d10 = 0.8; | |
_qword_1d18 = 9.25; | |
_qword_1d20 = 7.25; | |
_qword_1d28 = 50.0; | |
_qword_1d30 = 1.02; | |
_qword_1d38 = 60.0; | |
_qword_1d40 = 0.96; | |
_qword_1d48 = 160.0; | |
_qword_1d50 = 1.03; | |
_qword_1d58 = 61.0; | |
_qword_1d60 = 0.98; | |
_qword_1d68 = 1.0; | |
_qword_1d70 = 75.0; | |
_qword_1d78 = 5.0; | |
constructor(weight, height, age, sex, impedance) { | |
this.weight = weight; | |
this.height = height; | |
this.age = age; | |
this.sex = sex; | |
let x1 = impedance; | |
let x2 = impedance; | |
x1 = (x1 & 0xff0000) >> 0x10; | |
// x2 = (x2 & this.rr()); | |
x2 = x2 & 0xf00; | |
x1 = x1 + x2; | |
let x3 = (impedance & 0xf000) >> 0x0c; | |
let r8d = (impedance & 0xff) * -1 * 4; | |
x1 = x1 - x3; | |
x1 = x1 + r8d; | |
x1 = x1 * this._qword_1c38; | |
r8d = parseInt(x1); | |
let error = 4; | |
let xmm2 = this._qword_1c40; | |
this.twoLegs = r8d; | |
if (xmm2 <= this.height) { | |
if (this.height <= this._qword_1c48) { | |
error = 3; | |
if (this.age >= this._qword_1c50) { | |
if (this.age <= this._qword_1c58) { | |
error = 2; | |
if (this.age <= 99) { | |
error = 1; | |
if (r8d <= 3000) { | |
let x0 = r8d; | |
error = 0; | |
let temp = this._qword_1c60; | |
let overflow = this.checkValueOverflow( | |
r8d, | |
this._qword_1c58, | |
temp, | |
); | |
this.twoLegs = overflow; | |
} | |
} | |
} | |
} | |
} | |
} | |
this.errorMeasurement = error; | |
} | |
getLbmCoefficient() { | |
// Eq. (9.058 * (height ^ 2 / 100 ^ 2)) + 12.226 + (0.32 * weight) - (twoLegs * 0.0068) - (0.0542 * age); | |
let x = | |
this._qword_1c08 * | |
(Math.pow(this.height, 2) / Math.pow(this._qword_1c10, 2)); | |
let y = this._qword_1c20 * this.weight; | |
x = x + this._qword_1c18; | |
x = x + y; | |
let z1 = this.twoLegs * this._qword_1c28; | |
x = x - z1; | |
let z2 = this.age * this._qword_1c30; | |
x = x - z2; | |
return x; | |
} | |
checkValueOverflow(arg0, arg1, arg2) { | |
let max = Math.max(arg1, arg0); | |
let min = Math.min(arg2, max); | |
return min; | |
} | |
get bFP() { | |
let age = parseFloat(this.age); | |
let x0 = this.getLbmCoefficient(); | |
let sex = this.sex; | |
let COND = age > 49; | |
let x1 = 0; | |
if (!COND) { | |
x1 = this._qword_1d18; | |
if (sex == 1) { | |
x1 = this._qword_1d10; | |
} | |
} else { | |
x1 = this._qword_1c20; | |
if (sex == 1) { | |
x1 = this._qword_1d10; | |
} | |
} | |
let weight = this.weight; | |
x0 = x0 - x1; | |
if (sex == 0) { | |
let x2 = this._qword_1d28; | |
let COND2 = x2 < weight; | |
if (COND2) { | |
x0 = x0 * this._qword_1d30; | |
} | |
let COND3 = x1 > this._qword_1d38; | |
if (COND3) { | |
x0 = x0 * this._qword_1d40; | |
} | |
let weight = this.weight; | |
let COND4 = weight > this._qword_1d48; | |
if (COND2) { | |
x0 = x0 * this._qword_1d50; | |
} | |
} else { | |
let x2 = this._qword_1d58; | |
let COND2 = x2 > weight; | |
if (COND2) { | |
x0 = x0 * this._qword_1d60; | |
} | |
} | |
x1 = weight; | |
x0 = x0 / x1; | |
x1 = this._qword_1d68; | |
let bodyFatPercentage = this.bodyFatPercentage; | |
x1 = x1 - x0; | |
x1 = x1 * this._qword_1c10; | |
bodyFatPercentage = x1; | |
return bodyFatPercentage; | |
} | |
rr() { | |
return parseFloat(this.age); | |
} | |
} | |
export default BodyComposition; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment