<?php
header('Content-Type: text/html; charset=utf-8');
define ('ROOT', $_SERVER['DOCUMENT_ROOT']);
include ROOT.'/assets/php/head.php';
$tit= '求三角形各边各角度已知两边和第三边所夹两角';
/**
* a为30,b为40,ao为42,bo为63
* a为30,b为40,ao为37,bo为53
* a为30,b为40,ao为25,bo为35
*/
$val='30 40 25 35';
$img='';
//调用方法
mill($val,$img,$tit);
/**
* mill 是磨粉机的方法
* $val 传值过来计算,以空格分割成数值
* $img 自定义图片名,默认以文件名为图片名
* $tit 标题名
* */
function mill($val,$img,$tit){
//初始化
include ROOT.'/assets/php/init.php';
imgt($img,$tit);
//设置小数点保留位数
bcscale (2);
//$pi = round(pi(),2);
//以空格分割成数值
$vals = expl($val);
$a = evev($vals[0]);
$b = evev($vals[1]);
$ao = evev($vals[2]);
$bo = evev($vals[3]);
//已知条件
$know = array();
array_push($know, $val);
$v0 = eveq($vals[0]);
array_push($know, "a边长:$v0");
$v1 = eveq($vals[1]);
array_push($know, "b边长:$v1");
$v2 = eveq($vals[2]);
array_push($know, "{$math['ang']}a:$v2{$math['o']}");
$v2 = eveq($vals[3]);
array_push($know, "{$math['ang']}b:$v2{$math['o']}");
//计算步骤
$step = array();
array_push($step, "求三角形的c边:");
array_push($step, "{$math['eq']} $a{$math['mul']}cos{$bo}{$math['o']}{$math['add']}$b{$math['mul']}cos{$ao}{$math['o']}");
$cosbo = cos(deg2rad($bo));
$cosao = cos(deg2rad($ao));
array_push($step, "{$math['eq']} $a{$math['mul']}$cosbo{$math['add']}$b{$math['mul']}$cosao");
$cosboa = bcmul($a, $cosbo);
$cosaob = bcmul($b, $cosao);
array_push($step, "{$math['eq']} $cosboa{$math['add']}$cosaob");
$c = bcadd($cosboa, $cosaob);
array_push($step, "{$math['eq']} $c");
array_push($step, "求三角形的{$math['ang']}C:");
array_push($step, "{$math['eq']} arccos{$math['lsqb']}{$math['lpar']}$a{$math['sup2']}{$math['add']}$b{$math['sup2']}{$math['sub']}$c{$math['sup2']}{$math['rpar']}{$math['div']}{$math['lpar']}2{$math['mul']}$a{$math['mul']}$b{$math['rpar']}{$math['rsqb']}");
$aa = bcmul($a, $a);
$bb = bcmul($b, $b);
$cc = bcmul($c, $c);
array_push($step, "{$math['eq']} arccos{$math['lsqb']}{$math['lpar']}$aa{$math['add']}$bb{$math['sub']}$cc{$math['rpar']}{$math['div']}{$math['lpar']}2{$math['mul']}$a{$math['mul']}$b{$math['rpar']}{$math['rsqb']}");
$aabb = bcadd($aa, $bb);
$ab = bcmul($a, $b);
array_push($step, "{$math['eq']} arccos{$math['lsqb']}{$math['lpar']}$aabb{$math['sub']}$cc{$math['rpar']}{$math['div']}{$math['lpar']}2{$math['mul']}$ab{$math['rpar']}{$math['rsqb']}");
$aabbcc = bcsub($aabb, $cc);
$ab2 = bcmul($ab ,2);
array_push($step, "{$math['eq']} arccos{$math['lpar']}$aabbcc{$math['div']}$ab2{$math['rpar']}");
$aabbccab2 = $aabbcc/$ab2;
array_push($step, "{$math['eq']} arccos{$math['lpar']}$aabbccab2{$math['rpar']}");
$acosaabbccab2= acos($aabbccab2);
array_push($step, "{$math['eq']} 弧度值:{$acosaabbccab2}");
$co = rad2deg($acosaabbccab2);
array_push($step, "{$math['eq']} 角度值:{$co}{$math['o']}");
//算出结果
$ends = array();
array_push($ends, "三角形的a边:{$a}");
array_push($ends, "三角形的b边:{$b}");
array_push($ends, "三角形的c边:{$c}");
$aoo = round($ao,1);
$boo = round($bo,1);
$coo = round($co,1);
array_push($ends, "三角形的{$math['ang']}A:{$aoo}{$math['o']}");
array_push($ends, "三角形的{$math['ang']}B:{$boo}{$math['o']}");
array_push($ends, "三角形的{$math['ang']}C:{$coo}{$math['o']}");
//公式表示
$home = array();
array_push($home, "三角形的c边:c{$math['eq']}a{$math['mul']}cos{$math['ang']}B{$math['add']}b{$math['mul']}cos{$math['ang']}A");
array_push($home, "三角形的{$math['ang']}C:{$math['ang']}C{$math['eq']}arccos{$math['lsqb']}{$math['lpar']}a{$math['sup2']}{$math['add']}b{$math['sup2']}{$math['sub']}c{$math['sup2']}{$math['rpar']}{$math['sol']}2ab{$math['rsqb']}");
//解释说明
$info = array();
array_push($info, "三角函数的余弦定理,可求任意三角形");
array_push($info, "已知任意三角形的两边及两边所夹的角,求第三边:");
array_push($info, "a{$math['sup2']}{$math['eq']}b{$math['sup2']}{$math['add']}c{$math['sup2']}{$math['sub']}2bc{$math['mul']}cos{$math['ang']}A");
array_push($info, "b{$math['sup2']}{$math['eq']}a{$math['sup2']}{$math['add']}c{$math['sup2']}{$math['sub']}2ac{$math['mul']}cos{$math['ang']}B");
array_push($info, "c{$math['sup2']}{$math['eq']}a{$math['sup2']}{$math['add']}b{$math['sup2']}{$math['sub']}2ab{$math['mul']}cos{$math['ang']}C");
array_push($info, "已知三角形的两边及与第三边所夹的两角,求第三边:");
array_push($info, "a{$math['eq']}b{$math['mul']}cos{$math['ang']}C{$math['add']}c{$math['mul']}cos{$math['ang']}B");
array_push($info, "b{$math['eq']}c{$math['mul']}cos{$math['ang']}A{$math['add']}a{$math['mul']}cos{$math['ang']}C");
array_push($info, "c{$math['eq']}a{$math['mul']}cos{$math['ang']}B{$math['add']}b{$math['mul']}cos{$math['ang']}A");
array_push($info, "已知三角形的三边,求角度数:");
array_push($info, "cos{$math['ang']}A{$math['eq']}{$math['lpar']}c{$math['sup2']}{$math['add']}b{$math['sup2']}{$math['sub']}a{$math['sup2']}{$math['rpar']}{$math['sol']}2bc");
array_push($info, "cos{$math['ang']}B{$math['eq']}{$math['lpar']}a{$math['sup2']}{$math['add']}c{$math['sup2']}{$math['sub']}b{$math['sup2']}{$math['rpar']}{$math['sol']}2ac");
array_push($info, "cos{$math['ang']}C{$math['eq']}{$math['lpar']}a{$math['sup2']}{$math['add']}b{$math['sup2']}{$math['sub']}c{$math['sup2']}{$math['rpar']}{$math['sol']}2ab");
know($know);
ends($ends);
home($home);
step($step);
info($info);
}
?>
<?php include ROOT.'/assets/php/foot.php'; ?>
结果:
☁参考上图[2022-12-04]
☀求三角形各边各角度已知两边和第三边所夹两角
30 40 25 35
a边长:30
b边长:40
∠a:25°
∠b:35°
♠算出结果
三角形的a边:30
三角形的b边:40
三角形的c边:60.82
三角形的∠A:25°
三角形的∠B:35°
三角形的∠C:120°
♦公式表示
三角形的c边:c=a×cos∠B+b×cos∠A
三角形的∠C:∠C=arccos[(a²+b²−c²)/2ab]
♣计算步骤
求三角形的c边:
= 30×cos35°+40×cos25°
= 30×0.81915204428899+40×0.90630778703665
= 24.57+36.25
= 60.82
求三角形的∠C:
= arccos[(30²+40²−60.82²)÷(2×30×40)]
= arccos[(900.00+1600.00−3699.07)÷(2×30×40)]
= arccos[(2500.00−3699.07)÷(2×1200.00)]
= arccos(-1199.07÷2400.00)
= arccos(-0.4996125)
= 弧度值:2.0939477136999
= 角度值:119.97436651607°
♥解释说明
三角函数的余弦定理,可求任意三角形
已知任意三角形的两边及两边所夹的角,求第三边:
a²=b²+c²−2bc×cos∠A
b²=a²+c²−2ac×cos∠B
c²=a²+b²−2ab×cos∠C
已知三角形的两边及与第三边所夹的两角,求第三边:
a=b×cos∠C+c×cos∠B
b=c×cos∠A+a×cos∠C
c=a×cos∠B+b×cos∠A
已知三角形的三边,求角度数:
cos∠A=(c²+b²−a²)/2bc
cos∠B=(a²+c²−b²)/2ac
cos∠C=(a²+b²−c²)/2ab
标签:cos,30,40,arccos,已知,各边,100027,三角形,两角
From: https://www.cnblogs.com/onestopweb/p/16950302.html