Compare commits
2 Commits
333372348c
...
a10c84d077
Author | SHA1 | Date | |
---|---|---|---|
a10c84d077 | |||
42961eb08e |
51
analyser.js
51
analyser.js
@ -9,9 +9,9 @@ var dataElong = [];
|
||||
var dataAngle = [];
|
||||
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) {
|
||||
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 /////
|
||||
|
||||
///// START OF DISPLAY SECTION /////
|
||||
|
||||
///// ALGORITHMS SECTION /////
|
||||
|
||||
function addReduction() {
|
||||
numDies ++; // Increment our die count
|
||||
@ -72,7 +77,8 @@ function addReduction() {
|
||||
}
|
||||
|
||||
function removeReduction() { // function to remove the last row
|
||||
numDies --;
|
||||
if (numDies > 1) {
|
||||
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
|
||||
@ -84,12 +90,11 @@ function removeReduction() { // function to remove the last row
|
||||
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() {
|
||||
outputVisible = 1; // set visible status to enabled
|
||||
outputTable = document.getElementById("output"); // Select our output data table
|
||||
@ -138,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);
|
||||
@ -430,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 = "| ";
|
||||
@ -525,11 +521,12 @@ function clearScreen() {
|
||||
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() {
|
||||
var subtitle = document.getElementById("subtitle");
|
||||
var reductionCount = document.getElementById("numReductions");
|
||||
@ -537,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) + "\")";
|
||||
@ -545,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