首页 > 其他分享 >100017 求三角形面积和各边高已知三边各长

100017 求三角形面积和各边高已知三边各长

时间:2022-11-22 22:57:04浏览次数:55  
标签:13 15 边长 各长 100017 21.00 各边 三角形 14

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

$tit= '求三角形面积和各边高已知三边各长';
//已知a边长15,b边长14,c边长13
$val='15 14 13';
$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]);
    $c = evev($vals[2]);

    //已知条件
    $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, "a边长:$v2");

    //计算步骤
    $step = array();
    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, "底a{$math['lpar']}$a{$math['rpar']}的高:");
    array_push($step, "{$math['eq']} $S{$math['mul']}2{$math['div']}$a");
    $S2 = bcmul($S, 2);
    array_push($step, "{$math['eq']} $S2{$math['div']}$a");
    $h1 = bcdiv($S2, $a);
    array_push($step, "{$math['eq']} $h1");

    array_push($step, "底b{$math['lpar']}$b{$math['rpar']}的高:");
    array_push($step, "{$math['eq']} $S{$math['mul']}2{$math['div']}$b");
    $S2 = bcmul($S, 2);
    array_push($step, "{$math['eq']} $S2{$math['div']}$b");
    $h2 = bcdiv($S2, $b);
    array_push($step, "{$math['eq']} $h2");

    array_push($step, "底c{$math['lpar']}$c{$math['rpar']}的高:");
    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");
    $h3 = bcdiv($S2, $c);
    array_push($step, "{$math['eq']} $h3");

    //算出结果
    $ends = array();
    array_push($ends, "三角形的半周长:$p");
    array_push($ends, "三角形的面积:$S");
    array_push($ends, "底a{$math['lpar']}$a{$math['rpar']}的高:$h1");
    array_push($ends, "底b{$math['lpar']}$b{$math['rpar']}的高:$h2");
    array_push($ends, "底c{$math['lpar']}$c{$math['rpar']}的高:$h3");

    //公式表示
    $home = array();
    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, "底a的高:h{$sub['1']}{$math['eq']}2S{$math['sol']}a");
    array_push($home, "底b的高:h{$sub['2']}{$math['eq']}2S{$math['sol']}b");
    array_push($home, "底c的高:h{$sub['3']}{$math['eq']}2S{$math['sol']}c");

    //公式说明
    $info = array();
    array_push($info, "三角形的半周长 {$math['eq']} {$math['lpar']} 边长a {$math['add']} 边长b {$math['add']} 边长c {$math['rpar']} {$math['div']} 2。");
    array_push($info, "三角形的面积 {$math['eq']} 平方根{$math['lsqb']} 半周长 {$math['mul']} {$math['lpar']} 半周长 {$math['sub']} 边长a {$math['rpar']}{$math['mul']}{$math['lpar']} 半周长 {$math['sub']} 边长b {$math['rpar']}{$math['mul']}{$math['lpar']} 半周长 {$math['sub']}边长c {$math['rpar']}{$math['rsqb']}。");
    array_push($info, "底a的高 {$math['eq']} 面积 {$math['mul']} 2 {$math['div']} 边长a。");
    array_push($info, "底b的高 {$math['eq']} 面积 {$math['mul']} 2 {$math['div']} 边长b。");
    array_push($info, "底b的高 {$math['eq']} 面积 {$math['mul']} 2 {$math['div']} 边长c。");

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

结果:

☁参考上图[2022-11-22]

☀求三角形面积和各边高已知三边各长
15 14 13
a边长:15
b边长:14
a边长:13

♠算出结果
三角形的半周长:21.00
三角形的面积:84.00
底a(15)的高:11.20
底b(14)的高:12.00
底c(13)的高:12.92

♦公式表示
三角形的半周长:p=(a+b+c)/2
三角形的面积(海伦公式):S=√₍p(p−a)(p−b)(p−c)₎
底a的高:h₁=2S/a
底b的高:h₂=2S/b
底c的高:h₃=2S/c

♣计算步骤
三角形的半周长:
= (15+14+13)÷2
= (29.00+13)÷2
= 42.00÷2
= 21.00
三角形的面积:
= √₍21.00×(21.00−15)×(21.00−14)×(21.00−13)₎
= √₍21.00×6.00×7.00×8.00₎
= √₍21.00×42.00×8.00₎
= √₍21.00×336.00₎
= √7056.00
= 84.00
底a(15)的高:
= 84.00×2÷15
= 168.00÷15
= 11.20
底b(14)的高:
= 84.00×2÷14
= 168.00÷14
= 12.00
底c(13)的高:
= 84.00×2÷13
= 168.00÷13
= 12.92

♥公式解释
三角形的半周长 = ( 边长a + 边长b + 边长c ) ÷ 2。
三角形的面积 = 平方根[ 半周长 × ( 半周长 − 边长a )×( 半周长 − 边长b )×( 半周长 −边长c )]。
底a的高 = 面积 × 2 ÷ 边长a。
底b的高 = 面积 × 2 ÷ 边长b。
底b的高 = 面积 × 2 ÷ 边长c。

标签:13,15,边长,各长,100017,21.00,各边,三角形,14
From: https://www.cnblogs.com/onestopweb/p/16916780.html

相关文章