Show pageExport to PDFBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Prism Diopter to Degree Converter ====== <button type="primary" size="sm">[[prism_diopters_degrees_converter|Reload Converter]]</button> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Prism Diopter & Degree Converter</title> <style> body { font-family: Arial, sans-serif; margin: 20px; padding: 20px; max-width: 900px; } h2 { color: #333; } label { font-weight: bold; } input, button { margin-top: 5px; padding: 8px; font-size: 16px; } p { font-size: 18px; font-weight: bold; color: blue; margin-top: 10px; } </style> </head> <body> <!-- Convert Angle to Prism Diopter --> <h3>Convert Degrees to Prism Diopters</h3> <label for="angleInput">Enter Angle (1-90 degrees): </label> <input type="number" id="angleInput" style="width: 80px;" step="any" min="1" max="90"> <button onclick="convertToDiopters()">Convert</button> <p id="resultDiopters"></p> <hr> <!-- Convert Prism Diopter to Angle --> <h3>Convert Prism Diopters to Degrees</h3> <label for="diopterInput">Enter Prism Diopters: </label> <input type="number" id="diopterInput" style="width: 80px;" step="any"> <button onclick="convertToAngle()">Convert</button> <p id="resultAngle"></p> <script> function convertToDiopters() { let angle = parseFloat(document.getElementById("angleInput").value); let resultElement = document.getElementById("resultDiopters"); if (isNaN(angle) || angle < 1 || angle > 90) { resultElement.innerHTML = "Please enter an angle between 1 and 90 degrees."; return; } let prismDiopter = 100 * Math.tan(angle * (Math.PI / 180)); // Convert degrees to radians let roundedDiopter = Math.round(prismDiopter); // Round to whole number resultElement.innerHTML = `Prism Diopters: <b>${roundedDiopter}</b>`; } function convertToAngle() { let diopters = parseFloat(document.getElementById("diopterInput").value); let resultElement = document.getElementById("resultAngle"); if (isNaN(diopters)) { resultElement.innerHTML = "Please enter a valid prism diopter value."; return; } let angle = Math.atan(diopters / 100) * (180 / Math.PI); // Convert radians to degrees let roundedAngle = Math.round(angle); // Round to whole number resultElement.innerHTML = `Angle: <b>${roundedAngle}°</b>`; } // Allow "Enter" key to trigger conversion document.getElementById("angleInput").addEventListener("keypress", function(event) { if (event.key === "Enter") { convertToDiopters(); } }); document.getElementById("diopterInput").addEventListener("keypress", function(event) { if (event.key === "Enter") { convertToAngle(); } }); </script> </body> </html> {{tag>calculator prism}} calculator prism