首页 > 其他分享 >110001 求最短距离已知两点坐标

110001 求最短距离已知两点坐标

时间:2022-11-21 21:57:18浏览次数:70  
标签:10 12 110001 公式 坐标 短距离 两点

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

$tit= '求最短距离已知两点坐标';
//已知x1:7,y1:8,x2:10,y2:12
$val='7 8 10 12';
$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);
    $x1 = evev($vals[0]);
    $y1 = evev($vals[1]);
    $x2 = evev($vals[2]);
    $y2 = evev($vals[3]);

    //已知条件
    $know = array();
    array_push($know, $val);
    $v0 = eveq($vals[0]);
    array_push($know, "x1:$v0");
    $v1 = eveq($vals[1]);
    array_push($know, "y1:$v1");
    $v2 = eveq($vals[2]);
    array_push($know, "x2:$v2");
    $v3 = eveq($vals[3]);
    array_push($know, "y2:$v3");

    //计算步骤
    $step = array();
    array_push($step, "两点间距离公式:");
    array_push($step, "{$math['eq']} {$math['root2l']}{$math['abs']}$x1{$math['sub']}$x2{$math['abs']}{$math['sup2']}{$math['add']}{$math['abs']}$y1{$math['sub']}$y2{$math['abs']}{$math['sup2']}{$math['root2r']}");
    $x1x2 = bcsub($x1, $x2);
    $y1y2 = bcsub($y1, $y2);
    array_push($step, "{$math['eq']} {$math['root2l']}{$math['abs']}$x1x2{$math['abs']}{$math['sup2']}{$math['add']}{$math['abs']}$y1y2{$math['abs']}{$math['sup2']}{$math['root2r']}");
    $x1x2abs = abs($x1x2);
    $y1y2abs = abs($y1y2);
    array_push($step, "{$math['eq']} {$math['root2l']}$x1x2abs{$math['sup2']}{$math['add']}$y1y2abs{$math['sup2']}{$math['root2r']}");
    $x1x2abs2 = bcpow($x1x2abs, 2);
    $y1y2abs2 = bcpow($y1y2abs, 2);
    array_push($step, "{$math['eq']} {$math['root2l']}$x1x2abs2{$math['add']}$y1y2abs2{$math['root2r']}");
    $x1x2abs2y1y2abs2 = bcadd($x1x2abs2, $y1y2abs2);
    array_push($step, "{$math['eq']} {$math['root2']}$x1x2abs2y1y2abs2");
    $AB = bcsqrt($x1x2abs2y1y2abs2, 2);
    array_push($step, "{$math['eqs']} $AB");

    //算出结果
    $ends = array();
    array_push($ends, "最短距离:$AB");

    //公式表示
    $home = array();
    array_push($home, "两点间距离公式:AB{$math['eq']}{$math['root2l']}{$math['abs']}x1{$math['sub']}x2{$math['abs']}{$math['sup2']}{$math['add']}{$math['abs']}y1{$math['sub']}y2{$math['abs']}{$math['sup2']}{$math['root2r']}");

    //公式说明
    $info = array();
    array_push($info, "两点间距离公式: 最短距离 {$math['eq']} 根号2 {$math['lpar']} {$math['abs']}X1{$math['sub']}X2{$math['abs']}的平方 {$math['add']}{$math['abs']}Y1{$math['sub']}Y2{$math['abs']}的平方 {$math['rpar']}。");

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

结果:

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

☀求最短距离已知两点坐标
7 8 10 12
x1:7
y1:8
x2:10
y2:12

♠算出结果
最短距离:5.00

♦公式表示
两点间距离公式:AB=√₍|x1−x2|²+|y1−y2|²₎

♣计算步骤
两点间距离公式:
= √₍|7−10|²+|8−12|²₎
= √₍|-3.00|²+|-4.00|²₎
= √₍3²+4²₎
= √₍9.00+16.00₎
= √25.00
≈ 5.00

♥公式解释
两点间距离公式: 最短距离 = 根号2 ( |X1−X2|的平方 +|Y1−Y2|的平方 )。

标签:10,12,110001,公式,坐标,短距离,两点
From: https://www.cnblogs.com/onestopweb/p/16913492.html

相关文章