figbertmath

[RADIOACTIVE] miscellaneous math programs in website form
git clone git://git.figbert.com/figbertmath.git
Log | Files | Refs | README

commit cf50290319eacb7feb85a215e864da60c2283316
parent d1b4ae9f6143f828c56c98b3fbcd6d8b4969602f
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Mon, 25 Nov 2019 22:01:07 -0800

Add functionality to angular size/real size/distance calculator

Diffstat:
Msrc/components/angSize/angSizeHandler.js | 58++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 52 insertions(+), 6 deletions(-)

diff --git a/src/components/angSize/angSizeHandler.js b/src/components/angSize/angSizeHandler.js @@ -17,6 +17,9 @@ export class AngSizeCalc extends React.Component { }; this.onChange = this.onChange.bind(this); this.onClick = this.onClick.bind(this); + this.calcAngle = this.calcAngle.bind(this); + this.calcSize = this.calcSize.bind(this); + this.calcDistance = this.calcDistance.bind(this); } onClick(object) { @@ -25,36 +28,42 @@ export class AngSizeCalc extends React.Component { if (!this.state.aTruth && !(this.state.rTruth && this.state.dTruth)) { this.setState({ aVal: '', - aTruth: !this.state.aTruth + aTruth: !this.state.aTruth, + output: '' }); } else if (this.state.aTruth) { this.setState({ aVal: '', - aTruth: !this.state.aTruth + aTruth: !this.state.aTruth, + output: '' }); } } else if (objectID === 'r') { if (!this.state.rTruth && !(this.state.aTruth && this.state.dTruth)) { this.setState({ rVal: '', - rTruth: !this.state.rTruth + rTruth: !this.state.rTruth, + output: '' }); } else if (this.state.rTruth) { this.setState({ rVal: '', - rTruth: !this.state.rTruth + rTruth: !this.state.rTruth, + output: '' }); } } else if (objectID === 'd') { if (!this.state.dTruth && !(this.state.aTruth && this.state.rTruth)) { this.setState({ dVal: '', - dTruth: !this.state.dTruth + dTruth: !this.state.dTruth, + output: '' }); } else if (this.state.dTruth) { this.setState({ dVal: '', - dTruth: !this.state.dTruth + dTruth: !this.state.dTruth, + output: '' }); } } @@ -76,6 +85,43 @@ export class AngSizeCalc extends React.Component { dVal: value }); } + if (this.state.aTruth && this.state.rTruth) { + this.calcDistance() + } else if (this.state.aTruth && this.state.dTruth) { + this.calcSize() + } else if (this.state.rTruth && this.state.dTruth) { + this.calcAngle() + } + } + + calcDistance() { + const size = Number(this.state.rVal), + angle = Number(this.state.aVal), + distance = (180 * size) / (3.14 * angle), + message = 'd = ' + distance; + this.setState({ + output: message + }); + } + + calcSize() { + const angle = Number(this.state.aVal), + distance = Number(this.state.dVal), + size = (angle * 3.14 * distance) / 180, + message = 'r = ' + size; + this.setState({ + output: message + }); + } + + calcAngle() { + const size = Number(this.state.rVal), + distance = Number(this.state.dVal), + angle = (180 * size) / (3.14 * distance), + message = '⍺ = ' + angle; + this.setState({ + output: message + }); } render() {