Compare commits
2 Commits
333372348c
...
a10c84d077
Author | SHA1 | Date | |
---|---|---|---|
a10c84d077 | |||
42961eb08e |
69
analyser.js
69
analyser.js
@ -9,9 +9,9 @@ var dataElong = [];
|
|||||||
var dataAngle = [];
|
var dataAngle = [];
|
||||||
var dataDelta = [];
|
var dataDelta = [];
|
||||||
|
|
||||||
///// START OF MATHS FUNCTIONS /////
|
///// MATHS FUNCTIONS /////
|
||||||
|
|
||||||
// This function gets the reduction of area with two provided sizes, and returns it
|
// Calculate Reduction of Area
|
||||||
function getReduction(startSize, finalSize) {
|
function getReduction(startSize, finalSize) {
|
||||||
var startArea = Math.PI * ((startSize / 2) * (startSize / 2));
|
var startArea = Math.PI * ((startSize / 2) * (startSize / 2));
|
||||||
var finalArea = Math.PI * ((finalSize / 2) * (finalSize / 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;
|
return (Math.pow(startSize / finalSize, 2) - 1) * 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calculate delta
|
||||||
function getDelta(startSize, finalSize, angle) {
|
function getDelta(startSize, finalSize, angle) {
|
||||||
angle = (angle * 0.5) * (Math.PI / 180); // Convert to semi-angle and radians
|
angle = (angle * 0.5) * (Math.PI / 180); // Convert to semi-angle and radians
|
||||||
return ((startSize + finalSize) / (startSize - finalSize)) * Math.sin(angle);
|
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
|
function toMillimetres(size) { //convert to mm
|
||||||
size = Math.round((size * 100) * 25.4) / 100;
|
size = Math.round((size * 100) * 25.4) / 100;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert number to inches
|
||||||
function toInches(size) { //convert to inches
|
function toInches(size) { //convert to inches
|
||||||
size = Math.round((size * 1000) / 25.4) / 1000;
|
size = Math.round((size * 1000) / 25.4) / 1000;
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRoDiameter(startSize, finishSize){
|
|
||||||
return (startSize - finishSize) / ((startSize + finishSize) / 2) * 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
///// END OF MATHS SECTION /////
|
///// END OF MATHS SECTION /////
|
||||||
|
|
||||||
///// START OF DISPLAY SECTION /////
|
|
||||||
|
///// ALGORITHMS SECTION /////
|
||||||
|
|
||||||
function addReduction() {
|
function addReduction() {
|
||||||
numDies ++; // Increment our die count
|
numDies ++; // Increment our die count
|
||||||
@ -72,24 +77,24 @@ function addReduction() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function removeReduction() { // function to remove the last row
|
function removeReduction() { // function to remove the last row
|
||||||
numDies --;
|
if (numDies > 1) {
|
||||||
document.getElementById("data").deleteRow(-1); // delete the last row in the table
|
numDies--;
|
||||||
|
document.getElementById("data").deleteRow(-1); // delete the last row in the table
|
||||||
// Remove the last item in each array to remove the tick from the graph
|
|
||||||
dieCount.splice(-1);
|
|
||||||
dataROA.splice(-1);
|
|
||||||
dataElong.splice(-1);
|
|
||||||
dataDelta.splice(-1);
|
|
||||||
|
|
||||||
if (outputVisible == 1) { // Check if out output is visible and update immediately when adding dies
|
// Remove the last item in each array to remove the tick from the graph
|
||||||
doMath();
|
dieCount.splice(-1);
|
||||||
|
dataROA.splice(-1);
|
||||||
|
dataElong.splice(-1);
|
||||||
|
dataDelta.splice(-1);
|
||||||
|
|
||||||
|
if (outputVisible == 1) { // Check if out output is visible and update immediately when adding dies
|
||||||
|
doMath();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
numDies = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///// END OF DISPLAY SECTION /////
|
|
||||||
|
|
||||||
///// START OF ALGORITHMS SECTION /////
|
|
||||||
|
|
||||||
function doMath() {
|
function doMath() {
|
||||||
outputVisible = 1; // set visible status to enabled
|
outputVisible = 1; // set visible status to enabled
|
||||||
outputTable = document.getElementById("output"); // Select our output data table
|
outputTable = document.getElementById("output"); // Select our output data table
|
||||||
@ -138,20 +143,11 @@ function doMath() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Format our numbers to prevent maximum user stupidity
|
// Format our numbers to prevent maximum user stupidity
|
||||||
if (inSize < 10.0 && inSize > 0) { // If we have a 'proper' number i.e. ".130"
|
inSize = formatCheck(inSize);
|
||||||
inSize = Number(inSize);
|
outSize = formatCheck(outSize);
|
||||||
} 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
row[i] = outputTable.insertRow(i); // Add a new row to the END of the table
|
row[i] = outputTable.insertRow(i); // Add a new row to the END of the table
|
||||||
|
|
||||||
|
|
||||||
// Add all our cells to the table
|
// Add all our cells to the table
|
||||||
// We also give them HTML ID's to format things with CSS nicely
|
// We also give them HTML ID's to format things with CSS nicely
|
||||||
cell1 = row[i].insertCell(0);
|
cell1 = row[i].insertCell(0);
|
||||||
@ -430,7 +426,7 @@ function getStatistics() {
|
|||||||
// COL 1
|
// COL 1
|
||||||
c1.innerHTML = "Total R. Of Diameter: ";
|
c1.innerHTML = "Total R. Of Diameter: ";
|
||||||
c1.id = "statsCol4";
|
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";
|
c2.id = "statsCol5";
|
||||||
//
|
//
|
||||||
c3.innerHTML = "| ";
|
c3.innerHTML = "| ";
|
||||||
@ -525,11 +521,12 @@ function clearScreen() {
|
|||||||
addReduction();
|
addReduction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///// END ALGORITHMS SECTION /////
|
||||||
|
|
||||||
///// END OF ALGORITHMS SECTION /////
|
|
||||||
|
|
||||||
///// EXTRA SECTION /////
|
///// EXTRAs SECTION /////
|
||||||
|
|
||||||
|
// Convert the page to a print layout, and open the OS/browser print dialog
|
||||||
function printScreen() {
|
function printScreen() {
|
||||||
var subtitle = document.getElementById("subtitle");
|
var subtitle = document.getElementById("subtitle");
|
||||||
var reductionCount = document.getElementById("numReductions");
|
var reductionCount = document.getElementById("numReductions");
|
||||||
@ -537,7 +534,6 @@ function printScreen() {
|
|||||||
// Get input size, and format it
|
// Get input size, and format it
|
||||||
var inputSize = document.getElementById("die0").value;
|
var inputSize = document.getElementById("die0").value;
|
||||||
|
|
||||||
|
|
||||||
// If our start size is metric show that, otherwise swap them to show 'murican first
|
// If our start size is metric show that, otherwise swap them to show 'murican first
|
||||||
if (document.getElementById("metric").checked) {
|
if (document.getElementById("metric").checked) {
|
||||||
var inputText = inputSize + " mm (" + toInches(inputSize) + "\")";
|
var inputText = inputSize + " mm (" + toInches(inputSize) + "\")";
|
||||||
@ -545,7 +541,6 @@ function printScreen() {
|
|||||||
var inputText = formatCheck(inputSize) + "\" (" + toMillimetres(formatCheck(inputSize)) + " mm)";
|
var inputText = formatCheck(inputSize) + "\" (" + toMillimetres(formatCheck(inputSize)) + " mm)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get the final size and format it
|
// Get the final size and format it
|
||||||
var outputSize = document.getElementById("die" + numDies).value;
|
var outputSize = document.getElementById("die" + numDies).value;
|
||||||
outputSize = formatCheck(outputSize).toFixed(3);
|
outputSize = formatCheck(outputSize).toFixed(3);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user