Altered layout and fixed some comments, fixed total reduction of diameter display (was only two-digit accuracy is now three)
This commit is contained in:
parent
42961eb08e
commit
a10c84d077
43
analyser.js
43
analyser.js
@ -11,7 +11,7 @@ var dataDelta = [];
|
||||
|
||||
///// MATHS FUNCTIONS /////
|
||||
|
||||
// This function gets the reduction of area with two provided sizes, and returns it
|
||||
// Calculate Reduction of Area
|
||||
function getReduction(startSize, finalSize) {
|
||||
var startArea = Math.PI * ((startSize / 2) * (startSize / 2));
|
||||
var finalArea = Math.PI * ((finalSize / 2) * (finalSize / 2));
|
||||
@ -24,28 +24,33 @@ function getElongation(startSize, finalSize) {
|
||||
return (Math.pow(startSize / finalSize, 2) - 1) * 100;
|
||||
}
|
||||
|
||||
// Calculate delta
|
||||
function getDelta(startSize, finalSize, angle) {
|
||||
angle = (angle * 0.5) * (Math.PI / 180); // Convert to semi-angle and radians
|
||||
return ((startSize + finalSize) / (startSize - finalSize)) * Math.sin(angle);
|
||||
}
|
||||
|
||||
// Calculate Reduction of Diameter
|
||||
function getRoDiameter(startSize, finishSize){
|
||||
return (startSize - finishSize) / ((startSize + finishSize) / 2) * 100;
|
||||
}
|
||||
|
||||
// Convert number to millimetres
|
||||
function toMillimetres(size) { //convert to mm
|
||||
size = Math.round((size * 100) * 25.4) / 100;
|
||||
return size;
|
||||
}
|
||||
|
||||
// Convert number to inches
|
||||
function toInches(size) { //convert to inches
|
||||
size = Math.round((size * 1000) / 25.4) / 1000;
|
||||
return size;
|
||||
}
|
||||
|
||||
function getRoDiameter(startSize, finishSize){
|
||||
return (startSize - finishSize) / ((startSize + finishSize) / 2) * 100;
|
||||
}
|
||||
|
||||
///// END OF MATHS SECTION /////
|
||||
|
||||
///// DISPLAY SECTION /////
|
||||
|
||||
///// ALGORITHMS SECTION /////
|
||||
|
||||
function addReduction() {
|
||||
numDies ++; // Increment our die count
|
||||
@ -90,10 +95,6 @@ function removeReduction() { // function to remove the last row
|
||||
}
|
||||
}
|
||||
|
||||
///// END OF DISPLAY SECTION /////
|
||||
|
||||
///// ALGORITHMS SECTION /////
|
||||
|
||||
function doMath() {
|
||||
outputVisible = 1; // set visible status to enabled
|
||||
outputTable = document.getElementById("output"); // Select our output data table
|
||||
@ -142,20 +143,11 @@ function doMath() {
|
||||
}
|
||||
|
||||
// Format our numbers to prevent maximum user stupidity
|
||||
if (inSize < 10.0 && inSize > 0) { // If we have a 'proper' number i.e. ".130"
|
||||
inSize = Number(inSize);
|
||||
} else { // re-format the number if it's 'wrong' i.e. "130"
|
||||
inSize = inSize / 1000;
|
||||
}
|
||||
if (outSize < 10.0 && outSize > 0) { // If we have a 'proper' number i.e. ".130"
|
||||
outSize = Number(outSize);
|
||||
} else { // re-format the number if it's 'wrong' i.e. "130"
|
||||
outSize = outSize / 1000;
|
||||
}
|
||||
inSize = formatCheck(inSize);
|
||||
outSize = formatCheck(outSize);
|
||||
|
||||
row[i] = outputTable.insertRow(i); // Add a new row to the END of the table
|
||||
|
||||
|
||||
// Add all our cells to the table
|
||||
// We also give them HTML ID's to format things with CSS nicely
|
||||
cell1 = row[i].insertCell(0);
|
||||
@ -434,7 +426,7 @@ function getStatistics() {
|
||||
// COL 1
|
||||
c1.innerHTML = "Total R. Of Diameter: ";
|
||||
c1.id = "statsCol4";
|
||||
c2.innerHTML = "<b>" + (Math.round((startSize - finalSize) * 1000) / 1000).toFixed(2) + "\"</b>";
|
||||
c2.innerHTML = "<b>" + (Math.round((startSize - finalSize) * 1000) / 1000).toFixed(3) + "\"</b>";
|
||||
c2.id = "statsCol5";
|
||||
//
|
||||
c3.innerHTML = "| ";
|
||||
@ -529,11 +521,12 @@ function clearScreen() {
|
||||
addReduction();
|
||||
}
|
||||
|
||||
|
||||
///// END ALGORITHMS SECTION /////
|
||||
|
||||
///// EXTRA SECTION /////
|
||||
|
||||
///// EXTRAs SECTION /////
|
||||
|
||||
// Convert the page to a print layout, and open the OS/browser print dialog
|
||||
function printScreen() {
|
||||
var subtitle = document.getElementById("subtitle");
|
||||
var reductionCount = document.getElementById("numReductions");
|
||||
@ -541,7 +534,6 @@ function printScreen() {
|
||||
// Get input size, and format it
|
||||
var inputSize = document.getElementById("die0").value;
|
||||
|
||||
|
||||
// If our start size is metric show that, otherwise swap them to show 'murican first
|
||||
if (document.getElementById("metric").checked) {
|
||||
var inputText = inputSize + " mm (" + toInches(inputSize) + "\")";
|
||||
@ -549,7 +541,6 @@ function printScreen() {
|
||||
var inputText = formatCheck(inputSize) + "\" (" + toMillimetres(formatCheck(inputSize)) + " mm)";
|
||||
}
|
||||
|
||||
|
||||
// Get the final size and format it
|
||||
var outputSize = document.getElementById("die" + numDies).value;
|
||||
outputSize = formatCheck(outputSize).toFixed(3);
|
||||
|
Loading…
x
Reference in New Issue
Block a user