Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@
<input type="text" id="workAreaWidthInput" value="2438" oninput="updateWorkAreaDimensions()">
<label for="workAreaHeightInput">Work Area Height:</label>
<input type="text" id="workAreaHeightInput" value="1219" oninput="updateWorkAreaDimensions()">

<div style="margin-top: 20px; padding-top: 20px; border-top: 1px solid #ccc;">
<h3 style="margin-top: 0;">Minimum Angles</h3>
<p><strong>Vertical Minimum Angle:</strong> <span id="verticalMinAngle">-</span>°</p>
<p><strong>Horizontal Minimum Angle:</strong> <span id="horizontalMinAngle">-</span>°</p>
<p><strong>Sin(Vertical):</strong> <span id="sinVertical">-</span></p>
<p><strong>Sin(Horizontal):</strong> <span id="sinHorizontal">-</span></p>
</div>
</div>
<script>
var canvas = document.getElementById('myCanvas');
Expand Down Expand Up @@ -142,6 +150,7 @@
trX = w;
trY = h;
brX = w;
updateMinimumAngles();
draw();
}
}
Expand All @@ -154,6 +163,7 @@
console.log("Width and height are defined");
woodHeight = parseInt(height);
woodWidth = parseInt(width);
updateMinimumAngles();
draw();
}
}
Expand Down Expand Up @@ -183,6 +193,47 @@
draw();
}

function updateMinimumAngles() {
// Get current dimensions
// Width and Height are the anchor spacing (trX and tlY)
const width = trX;
const height = tlY;

// Work Area dimensions
const workAreaWidth = woodWidth;
const workAreaHeight = woodHeight;

// Calculate gaps
const horizontalGap = (width - workAreaWidth) / 2;
const verticalGap = (height - workAreaHeight) / 2;

// Calculate Vertical Minimum Angle
// Adjacent = Horizontal Gap + Work Area Width
// Opposite = Vertical Gap
const verticalAdjacent = horizontalGap + workAreaWidth;
const verticalOpposite = verticalGap;
const verticalMinAngleRad = Math.atan(verticalOpposite / verticalAdjacent);
const verticalMinAngleDeg = verticalMinAngleRad * (180 / Math.PI);

// Calculate Horizontal Minimum Angle
// Adjacent = Vertical Gap + Work Area Height
// Opposite = Horizontal Gap
const horizontalAdjacent = verticalGap + workAreaHeight;
const horizontalOpposite = horizontalGap;
const horizontalMinAngleRad = Math.atan(horizontalOpposite / horizontalAdjacent);
const horizontalMinAngleDeg = horizontalMinAngleRad * (180 / Math.PI);

// Calculate sine values
const sinVertical = Math.sin(verticalMinAngleRad);
const sinHorizontal = Math.sin(horizontalMinAngleRad);

// Update display
document.getElementById('verticalMinAngle').textContent = verticalMinAngleDeg.toFixed(2);
document.getElementById('horizontalMinAngle').textContent = horizontalMinAngleDeg.toFixed(2);
document.getElementById('sinVertical').textContent = sinVertical.toFixed(4);
document.getElementById('sinHorizontal').textContent = sinHorizontal.toFixed(4);
}

//Shifts 0,0 to be the center of the canvas and scales the points for zooming
function projection(point) {
return { x: point.x * scale + canvas.width / 2 + panX, y: -point.y * scale + canvas.height / 2 + panY };
Expand Down Expand Up @@ -490,6 +541,7 @@
draw();
});

updateMinimumAngles();
draw();
</script>
</body>
Expand Down