This commit is contained in:
tsf 2024-05-06 18:17:24 +08:00
parent 7dea8a9edc
commit c165975e00
1 changed files with 222 additions and 0 deletions

222
public/tsf/jisuan.html Normal file
View File

@ -0,0 +1,222 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.container_all{
display: flex;
flex-direction: column;
flex-wrap: nowrap;
align-items: center;
}
.container{
width: 1000px;
height: 500px;
border: 1px solid black;
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-content: space-around;
justify-content: space-around;
background-color: antiquewhite;
/* background-color: coral; */
}
.content{
width: 490px;
height: 240px;
border: 1px solid black;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: flex-start;
}
.c_content_t{
width:auto;
height: 30px;
font-weight: bold;
font-size: 30px;
text-align: center;
line-height: 30px;
margin-bottom: 5px;
}
.c_content_b{
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
}
.c_content_l{
width: 350px;
height: 200px;
display: flex;
flex-direction: column;
justify-content: space-around;
flex-wrap: wrap;
}
.c_content_l div{
width: 175px;
height:20px;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
}
.c_content_l input{
width: 80px;
}
</style>
</head>
<body>
<div class="container_all">
<div>公式F=Mx(sinB+f1xcosB)xg+PxLx(sinB+f2xcosB)xg</div>
<div class="container">
<div class="content" style="background-color: burlywood;">
<div class="c_content_t">
求解F
</div>
<div class="c_content_b">
<div class="c_content_l">
<div><span>参数M</span><input id="F_M" type="text"></div>
<div><span>参数sinB</span><input id="F_sinB" type="text" placeholder="30°就填写30"></div>
<div><span>参数cosB</span><input id="F_cosB" type="text" placeholder="30°就填写30"></div>
<div><span>参数f1</span><input id="F_f1" type="text" value="0.015"></div>
<div><span>参数f2</span><input id="F_f2" type="text" value="0.2"></div>
<div><span>参数g</span><input id="F_g" type="text" value="9.8"></div>
<div><span>参数P</span><input id="F_P" type="text"></div>
<div><span>参数L</span><input id="F_L" type="text"></div>
<div><span></span><button onclick="calculateF()">计算</button></div>
</div>
<div class="c_content_r">
结果:<span id="F_F"></span>
</div>
</div>
</div>
<div class="content" style="background-color: coral;">
<div class="c_content_t">
求解M
</div>
<div class="c_content_b">
<div class="c_content_l">
<div><span>参数F</span><input id="M_F" type="text"></div>
<div><span>参数sinB</span><input id="M_sinB" type="text"></div>
<div><span>参数cosB</span><input id="M_cosB" type="text"></div>
<div><span>参数f1</span><input id="M_f1" type="text" value="0.015"></div>
<div><span>参数f2</span><input id="M_f2" type="text" value="0.2"></div>
<div><span>参数g</span><input id="M_g" type="text" value="9.8"></div>
<div><span>参数P</span><input id="M_P" type="text"></div>
<div><span>参数L</span><input id="M_L" type="text"></div>
<div><span></span><button onclick="solveForM()">计算</button></div>
</div>
<div class="c_content_r">
结果:<span id="M_M"></span>
</div>
</div>
</div>
<div class="content">
<div class="c_content_t">
求解??:
</div>
<div class="c_content_b">
</div>
</div>
<div class="content">
<div class="c_content_t">
求解??:
</div>
<div class="c_content_b">
</div>
</div>
</div>
</div>
</body>
</html>
<script>
// 固定的参数值
const f1 = 0.015;
const f2 = 0.2;
const g = 9.8;
// 计算F的函数
// function calculateF(M, sinB, cosB, P, L) {
function calculateF() {
var F_M = document.getElementById("F_M").value;
var F_sinB = document.getElementById("F_sinB").value;
var F_cosB = document.getElementById("F_cosB").value;
var F_f1 = document.getElementById("F_f1").value;
var F_f2 = document.getElementById("F_f2").value;
var F_g = document.getElementById("F_g").value;
var F_P = document.getElementById("F_P").value;
var F_L = document.getElementById("F_L").value;
// console.log(F_sinB)
// console.log(toRadians(F_sinB))
F_sinB = Math.floor(Math.sin(toRadians(F_sinB))*1000)/1000
F_cosB = Math.floor(Math.cos(toRadians(F_cosB))*1000)/1000
// console.log(F_sinB+'-----'+F_cosB)
// return
// return M * (sinB + f1 * cosB) * g + P * L * (sinB + f2 * cosB) * g;
var result = F_M * (F_sinB + F_f1 * F_cosB) * F_g + F_P * F_L * (F_sinB + F_f2 * F_cosB) * F_g;
console.log(result)
document.getElementById('F_F').innerHTML = result
}
// 假设其他参数已知求解M的函数简化后的方程
// function solveForM(F, sinB, cosB, P, L) {
function solveForM() {
var M_F = document.getElementById("M_F").value;
var M_sinB = document.getElementById("M_sinB").value;
var M_cosB = document.getElementById("M_cosB").value;
var M_f1 = document.getElementById("M_f1").value;
var M_f2 = document.getElementById("M_f2").value;
var M_g = document.getElementById("M_g").value;
var M_P = document.getElementById("M_P").value;
var M_L = document.getElementById("M_L").value;
// 简化方程来求解M
// 注意这里假设sinB + f1 * cosB不为0
// M_sinB = Math.sin(toRadians(M_sinB))
// M_cosB = Math.cos(toRadians(M_cosB))
M_sinB = Math.floor(Math.sin(toRadians(M_sinB))*1000)/1000
M_cosB = Math.floor(Math.cos(toRadians(M_cosB))*1000)/1000
console.log(M_sinB)
console.log(M_cosB)
const denominator = (M_sinB + M_f1 * M_cosB) * M_g;
if (denominator === 0) {
alert('sinB + f1 * cosB的结果不可以为0')
// throw new Error('sinB + f1 * cosB cannot be zero');
}
console.log(M_sinB + M_f2 * M_cosB)
console.log(denominator)
// return (F - P * L * (sinB + f2 * cosB) * g) / denominator;
var result = (M_F - M_P * M_L * (M_sinB + M_f2 * M_cosB) * M_g) / denominator;
document.getElementById('M_M').innerHTML = result
}
// 将角度转换为弧度
function toRadians(degrees) {
return degrees * (Math.PI / 180);
}
// // 示例使用calculateF函数
// const M_example = 10;
// const sinB_example = 0.5;
// const cosB_example = Math.sqrt(1 - Math.pow(sinB_example, 2));
// const P_example = 5;
// const L_example = 2;
// const F_value = calculateF(M_example, sinB_example, cosB_example, P_example, L_example);
// console.log(`F的值为: ${F_value.toFixed(2)}`); // 精确到小数点后两位
// // 示例使用solveForM函数
// const F_given = 100;
// const M_value = solveForM(F_given, sinB_example, cosB_example, P_example, L_example);
// console.log(`求解得到的M的值为: ${M_value.toFixed(2)}`); // 精确到小数点后两位
</script>