Compare commits
No commits in common. "a10c84d0771e6472a267e930abd3e9fa2b233983" and "333372348c58937734ba942152e05b102041ba22" have entirely different histories.
a10c84d077
...
333372348c
51
analyser.js
51
analyser.js
@ -9,9 +9,9 @@ var dataElong = [];
|
|||||||
var dataAngle = [];
|
var dataAngle = [];
|
||||||
var dataDelta = [];
|
var dataDelta = [];
|
||||||
|
|
||||||
///// MATHS FUNCTIONS /////
|
///// START OF MATHS FUNCTIONS /////
|
||||||
|
|
||||||
// Calculate Reduction of Area
|
// This function gets the reduction of area with two provided sizes, and returns it
|
||||||
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,33 +24,28 @@ 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
|
||||||
@ -77,8 +72,7 @@ function addReduction() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function removeReduction() { // function to remove the last row
|
function removeReduction() { // function to remove the last row
|
||||||
if (numDies > 1) {
|
numDies --;
|
||||||
numDies--;
|
|
||||||
document.getElementById("data").deleteRow(-1); // delete the last row in the table
|
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
|
// Remove the last item in each array to remove the tick from the graph
|
||||||
@ -90,11 +84,12 @@ function removeReduction() { // function to remove the last row
|
|||||||
if (outputVisible == 1) { // Check if out output is visible and update immediately when adding dies
|
if (outputVisible == 1) { // Check if out output is visible and update immediately when adding dies
|
||||||
doMath();
|
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
|
||||||
@ -143,11 +138,20 @@ function doMath() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Format our numbers to prevent maximum user stupidity
|
// Format our numbers to prevent maximum user stupidity
|
||||||
inSize = formatCheck(inSize);
|
if (inSize < 10.0 && inSize > 0) { // If we have a 'proper' number i.e. ".130"
|
||||||
outSize = formatCheck(outSize);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
@ -426,7 +430,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(3) + "\"</b>";
|
c2.innerHTML = "<b>" + (Math.round((startSize - finalSize) * 1000) / 1000).toFixed(2) + "\"</b>";
|
||||||
c2.id = "statsCol5";
|
c2.id = "statsCol5";
|
||||||
//
|
//
|
||||||
c3.innerHTML = "| ";
|
c3.innerHTML = "| ";
|
||||||
@ -521,12 +525,11 @@ function clearScreen() {
|
|||||||
addReduction();
|
addReduction();
|
||||||
}
|
}
|
||||||
|
|
||||||
///// END ALGORITHMS SECTION /////
|
|
||||||
|
|
||||||
|
///// END OF ALGORITHMS SECTION /////
|
||||||
|
|
||||||
///// EXTRAs SECTION /////
|
///// EXTRA 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");
|
||||||
@ -534,6 +537,7 @@ 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) + "\")";
|
||||||
@ -541,6 +545,7 @@ 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