100027 求三角形各邊各角度已知兩邊和第三邊所夾兩角
阿新 • • 發佈:2022-12-04
<?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