-
-
Save OrcaXS/7ec95ab8bcae8e31d5e0edb1fe14b88d to your computer and use it in GitHub Desktop.
Curve Calc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Curve</title> | |
<script defer> | |
//弧长c 拱高h - 半径r 弦长l | |
// 圆心角a | |
function calcR1(h, l) { | |
const r = ( Math.pow(h,2) + Math.pow((l/2),2) )/ 2/h; | |
const a = 2 * Math.asin( l / 2 / h ); | |
const c = a * r; | |
console.log("calcR1") | |
return r;s | |
} | |
//弦长l 拱高h - 半径r 弧长c | |
function onClick(){ | |
console.log("click") | |
const h = document.querySelector("#h").value || 0; | |
const l = document.querySelector("#l").value || 0; | |
document.querySelector("#calculatedR").innerHTML = calcR1(h, l); | |
} | |
document.addEventListener("DOMContentLoaded", () => { | |
document.querySelector('#calc').addEventListener('click', onClick); | |
}); | |
</script> | |
</head> | |
<body> | |
<fieldset> | |
<legend>弦长 拱高 - 半径 弧长</legend> | |
<label for="l">弦长</label> | |
<input type="number" name="l" id="l"><br /> | |
<label for="h">拱高</label> | |
<input type="number" name="h" id="h"><br /> | |
<button type="button" name="calc" id="calc" onclick="click()"> 计算 </button> | |
<button type="reset" name="reset" id="reset"> 归零 </button> | |
<br /> | |
半径<span id="calculatedR"></span><br /> | |
弧长<span id="calculatedC"></span> | |
</fieldset> | |
--------------<br /> | |
弧长<br /> | |
拱高<br /> | |
<br /> | |
弦长<br /> | |
半径<br /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment