1. 程式人生 > 其它 >100023 求三角形型別各角度周長面積已知三邊

100023 求三角形型別各角度周長面積已知三邊

<?php
header('Content-Type: text/html; charset=utf-8');
define ('ROOT', $_SERVER['DOCUMENT_ROOT']);
include ROOT.'/assets/php/head.php';

$tit= '求三角形型別各角度周長面積已知三邊';
/**
 * x邊30 ,y為40,z為43
 * x邊30 ,y為40,z為50
 * x邊30 ,y為40,z為61
 */
$val='61 30 40';
$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);
    $x = evev($vals[0]);
    $y = evev($vals[1]);
    $z = evev($vals[2]);

    //已知條件
    $know = array();
    array_push($know, $val);
    $v0 = eveq($vals[0]);
    $v1 = eveq($vals[1]);
    $v2 = eveq($vals[2]);
    array_push($know, "設x邊長為:{$v0}");
    array_push($know, "設y邊長為:{$v1}");
    array_push($know, "設z邊長為:{$v2}");
    array_push($know, "進行陣列排序賦值,a邊長取最小值,b邊長取中間值,c邊長取最大值:");
    $arr = array($x, $y ,$z);
    sort($arr);
    $a = $arr[0];
    array_push($know, "a邊長:{$a}");
    $b = $arr[1];
    array_push($know, "b邊長:{$b}");
    $c = $arr[2];
    array_push($know, "c邊長:{$c}");
    if($c >= ($a+$b)){ array_push($know, "<span style='color:#f00;'>注意: {$c} 大於等於 {$math['lpar']}$a{$math['add']}$b{$math['rpar']},無法組成三角形</span>");}

    //計算步驟
    $step = array();
    array_push($step, "求三角形的型別:設假c");
    array_push($step, "{$math['eq']} {$math['root2l']}$a{$math['sup2']}{$math['add']}$b{$math['sup2']}{$math['root2r']}");
    $aa = bcmul($a, $a);
    $bb = bcmul($b, $b);
    array_push($step, "{$math['eq']} {$math['root2l']}$aa{$math['add']}$bb{$math['root2r']}");
    $aabb = bcadd($aa, $bb );
    array_push($step, "{$math['eq']} {$math['root2l']}{$aabb}{$math['root2r']}");
    $c2 = bcsqrt($aabb);
    array_push($step, "{$math['eq']} $c2");
    $c2c ='';
    if($c < $c2){ $c2c = "銳角三角形"; }else if($c == $c2){ $c2c = "直角三角形";}else{$c2c = "鈍角三角形";}
    array_push($step, "{$math['eq']} 比較得知型別: {$c2c}");

    array_push($step, "求三角形的半周長:");
    array_push($step, "{$math['eq']} {$math['lpar']}$a{$math['add']}$b{$math['add']}$c{$math['rpar']}{$math['div']}2");
    $ab = bcadd($a, $b);
    array_push($step, "{$math['eq']} {$math['lpar']}$ab{$math['add']}$c{$math['rpar']}{$math['div']}2");
    $abc = bcadd($ab, $c);
    array_push($step, "{$math['eq']} $abc{$math['div']}2");
    $p = bcdiv($abc, 2);
    array_push($step, "{$math['eq']} $p");

    array_push($step, "求三角形的面積:");
    array_push($step, "{$math['eq']} {$math['root2l']}$p{$math['mul']}{$math['lpar']}$p{$math['sub']}$a{$math['rpar']}{$math['mul']}{$math['lpar']}$p{$math['sub']}$b{$math['rpar']}{$math['mul']}{$math['lpar']}$p{$math['sub']}$c{$math['rpar']}{$math['root2r']}");
    $pa = bcsub($p, $a);
    $pb = bcsub($p, $b);
    $pc = bcsub($p, $c);
    array_push($step, "{$math['eq']} {$math['root2l']}$p{$math['mul']}$pa{$math['mul']}$pb{$math['mul']}$pc{$math['root2r']}");
    $papb = bcmul($pa, $pb);
    array_push($step, "{$math['eq']} {$math['root2l']}$p{$math['mul']}$papb{$math['mul']}$pc{$math['root2r']}");
    $papbpc = bcmul($papb, $pc);
    array_push($step, "{$math['eq']} {$math['root2l']}$p{$math['mul']}$papbpc{$math['root2r']}");
    $ppapbpc = bcmul($p, $papbpc);
    array_push($step, "{$math['eq']} {$math['root2']}$ppapbpc");
    $S = bcsqrt($ppapbpc);
    array_push($step, "{$math['eq']} $S");

    array_push($step, "求三角形的周長:");
    array_push($step, "{$math['eq']} $a{$math['add']}$b{$math['add']}$c");
    $ab = bcadd($a, $b);
    array_push($step, "{$math['eq']} $ab{$math['add']}$c");
    $C = bcadd($ab, $c);
    array_push($step, "{$math['eq']} $C");

    array_push($step, "求三角形的c邊{$math['lpar']}$c{$math['rpar']}h高:");
    array_push($step, "{$math['eq']} $S{$math['mul']}2{$math['div']}$c");
    $S2 = bcmul($S, 2);
    array_push($step, "{$math['eq']} $S2{$math['div']}$c");
    $h = bcdiv($S2, $c);
    array_push($step, "{$math['eq']} $h");

    array_push($step, "求三角形的{$math['ang']}A:");
    array_push($step, "{$math['eq']} arcsin{$math['lpar']}$h{$math['div']}$b{$math['rpar']}");
    $hb = $h/$b;
    array_push($step, "{$math['eq']} arcsin{$math['lpar']}$hb{$math['rpar']}");
    $asinhb = asin($hb);
    array_push($step, "{$math['eq']} 弧度值:{$asinhb}");
    $ao = round(rad2deg($asinhb),1);
    array_push($step, "{$math['eq']} 角度值:{$ao}{$math['o']}");

    array_push($step, "求三角形的{$math['ang']}B:");
    array_push($step, "{$math['eq']} arcsin{$math['lpar']}$h{$math['div']}$a{$math['rpar']}");
    $ha = $h/$a;
    array_push($step, "{$math['eq']} arcsin{$math['lpar']}$ha{$math['rpar']}");
    $asinha = asin($ha);
    array_push($step, "{$math['eq']} 弧度值:{$asinha}");
    $bo = round(rad2deg($asinha),1);
    array_push($step, "{$math['eq']} 角度值:{$bo}{$math['o']}");

    array_push($step, "求三角形的{$math['ang']}C:");
    array_push($step, "{$math['eq']} 180{$math['o']}{$math['sub']}{$ao}{$math['o']}{$math['sub']}{$bo}{$math['o']}");
    $ao180 = bcsub(180, $ao);
    array_push($step, "{$math['eq']} $ao180{$math['sub']}{$bo}{$math['o']}");
    $co = bcsub($ao180, $bo);
    array_push($step, "{$math['eq']} 角度值:{$co}{$math['o']}");

    
    //算出結果
    $ends = array();
    array_push($ends, "三角形的型別:{$c2c}");
    array_push($ends, "三角形的a邊:{$a}");
    array_push($ends, "三角形的b邊:{$b}");
    array_push($ends, "三角形的c邊:{$c}");
    array_push($ends, "三角形的{$math['ang']}A:{$ao}{$math['o']}");
    array_push($ends, "三角形的{$math['ang']}B:{$bo}{$math['o']}");
    array_push($ends, "三角形的{$math['ang']}C:{$co}{$math['o']}");
    array_push($ends, "三角形的面積:{$S}");
    array_push($ends, "三角形的周長:{$C}");
     array_push($ends, "三角形的半周長:{$p}");
    array_push($ends, "三角形的c邊{$math['lpar']}$c{$math['rpar']}h高:$h");

    //公式表示
    $home = array();
    array_push($home, "三角形的型別:設假c,假c{$math['eq']}{$math['root2l']}a{$math['sup2']}{$math['add']}b{$math['sup2']}{$math['root2r']},假c和原c比較得知型別。");
    array_push($home, "三角形的半周長:p{$math['eq']}{$math['lpar']}a{$math['add']}b{$math['add']}c{$math['rpar']}{$math['sol']}2");
    array_push($home, "三角形的面積(海倫公式):S{$math['eq']}{$math['root2l']}p{$math['lpar']}p{$math['sub']}a{$math['rpar']}{$math['lpar']}p{$math['sub']}b{$math['rpar']}{$math['lpar']}p{$math['sub']}c{$math['rpar']}{$math['root2r']}");
    array_push($home, "三角形的周長:C{$math['eq']}a{$math['add']}b{$math['add']}c");
    array_push($home, "三角形的c邊h高:h{$math['eq']}2S{$math['sol']}c");
    array_push($home, "求三角形的{$math['ang']}A:arcsin{$math['lpar']}h{$math['sol']}b{$math['rpar']}");
    array_push($home, "求三角形的{$math['ang']}B:arcsin{$math['lpar']}h{$math['sol']}a{$math['rpar']}");
    array_push($home, "求三角形的{$math['ang']}C:180{$math['o']}{$math['sub']}{$math['ang']}A{$math['sub']}{$math['ang']}B");

    //公式說明
    $info = array();
    array_push($info, "勾股定理實際上是一個數學恆等式,它是一個基本的幾何定理,解決了直角三角形的{$math['quot']}邊的關係{$math['quot']}。");
    array_push($info, "三角函式則將幾何問題數字化,解決了三角形的邊角關係。");
    array_push($info, "勾股定理雖然只適用於直角三角形,而不適用於任意角的三角函式。");
    array_push($info, "但由於誘導公式使得任意角三角函式的求值問題可以轉化為0°到90°角的求值問題,");
    array_push($info, "這就為勾股定理直接應用於任意角三角函式及反三角函式的求值創造了條件。");

    know($know);
    ends($ends);
    home($home);
    step($step);
    info($info);
}
?>
<?php include ROOT.'/assets/php/foot.php'; ?>

結果:

☁參考上圖[2022-11-29]

☀求三角形型別各角度周長面積已知三邊
61 30 40
設x邊長為:61
設y邊長為:30
設z邊長為:40
進行陣列排序賦值,a邊長取最小值,b邊長取中間值,c邊長取最大值:
a邊長:30
b邊長:40
c邊長:61

♠算出結果
三角形的型別:鈍角三角形
三角形的a邊:30
三角形的b邊:40
三角形的c邊:61
三角形的∠A:25°
三角形的∠B:34.4°
三角形的∠C:120.60°
三角形的面積:516.54
三角形的周長:131.00
三角形的半周長:65.50
三角形的c邊(61)h高:16.93

♦公式表示
三角形的型別:設假c,假c=√₍a²+b²₎,假c和原c比較得知型別。
三角形的半周長:p=(a+b+c)/2
三角形的面積(海倫公式):S=√₍p(p−a)(p−b)(p−c)₎
三角形的周長:C=a+b+c
三角形的c邊h高:h=2S/c
求三角形的∠A:arcsin(h/b)
求三角形的∠B:arcsin(h/a)
求三角形的∠C:180°−∠A−∠B

♣計算步驟
求三角形的型別:設假c
= √₍30²+40²₎
= √₍900.00+1600.00₎
= √₍2500.00₎
= 50.00
= 比較得知型別: 鈍角三角形
求三角形的半周長:
= (30+40+61)÷2
= (70.00+61)÷2
= 131.00÷2
= 65.50
求三角形的面積:
= √₍65.50×(65.50−30)×(65.50−40)×(65.50−61)₎
= √₍65.50×35.50×25.50×4.50₎
= √₍65.50×905.25×4.50₎
= √₍65.50×4073.62₎
= √266822.11
= 516.54
求三角形的周長:
= 30+40+61
= 70.00+61
= 131.00
求三角形的c邊(61)h高:
= 516.54×2÷61
= 1033.08÷61
= 16.93
求三角形的∠A:
= arcsin(16.93÷40)
= arcsin(0.42325)
= 弧度值:0.43702947242098
= 角度值:25°
求三角形的∠B:
= arcsin(16.93÷30)
= arcsin(0.56433333333333)
= 弧度值:0.59962548511833
= 角度值:34.4°
求三角形的∠C:
= 180°−25°−34.4°
= 155.00−34.4°
= 角度值:120.60°

♥公式解釋
勾股定理實際上是一個數學恆等式,它是一個基本的幾何定理,解決了直角三角形的"邊的關係"。
三角函式則將幾何問題數字化,解決了三角形的邊角關係。
勾股定理雖然只適用於直角三角形,而不適用於任意角的三角函式。
但由於誘導公式使得任意角三角函式的求值問題可以轉化為0°到90°角的求值問題,
這就為勾股定理直接應用於任意角三角函式及反三角函式的求值創造了條件。