当我们知道基线垂直和斜边时,如何在php中查找角度?

时间:2015-04-23 08:21:20

标签: php base angle hypotenuse

当我们知道基线垂直和斜边时,在PHP中查找角度?

我正在用PHP制作一个项目并需要我一些计算但我无法想象当知道基线垂直和斜边时如何找出角度

Find Angle

这是:
AB = 3000 = BASE
BC = 1000 = PERPENDICULAR
AC =我在php脚本中找到如下

但是我需要在AB到AC或A°之间找出角度

  

在PHP中查找 HYPOTENUSE 的脚本,如下所示

<?php 
if(isset($_GET['f']) and ($_GET['t'])){
    $fr = $_GET['f'];
    $to = $_GET['t'];
    $xf = explode(', ',$fr);
    $xt = explode(', ',$to);

    $ans1   =   $xf[0]-$xt[0];
    $ans2   =   $xf[1]-$xt[1];
    $ans3   =   $ans1*$ans1;
    $ans4   =   $ans2*$ans2;
    $ans5   =   (sqrt($ans3+$ans4))*111.2;
} else {
    $fr = $to = $ans5 = "";
}
?>




<form action="" method="GET">
From:<br>
<input type="text" name="f" value="<?php echo $fr; ?>"></input>
<p></p>
To:<br>
<input type="text" name="t" value="<?php echo $to; ?>"></input>
<p></p>
<button type="submit">CALCULATE</button>
</form>
<hr>
<div>
<?php 
echo 'Distance: <strong>'.round($ans5*1000, 2).'</strong> meter(s)';
echo ' or <strong>'.round(($ans5), 3).'</strong> kilometer(s)<br>';
echo 'Distance: <strong>'.round(($ans5*0.621371), 3).'</strong> Mile(s)<br>';
echo 'Distance: <strong>'.round(($ans5*1000*3.28084), 2).'</strong> Foot';?>
</div>
<hr>

1 个答案:

答案 0 :(得分:0)

您可以使用我制作的类似内容来计算将文本从左下角到右上角放置到图像中的角度。

$image_hypotenuse = hypot($image_width, $image_height);
$a = $image_hypotenuse;
$b = $image_height;
$c = $image_width;
$a2 = $a * $a;
$b2 = $b * $b;
$c2 = $c * $c;
$alpha = rad2deg(acos(($b2 + $c2 - $a2) / (2 * $b * $c)));
$beta = rad2deg(acos(($a2 + $c2 - $b2) / (2 * $a * $c)));
$gamma = rad2deg(acos(($a2 + $b2 - $c2) / (2 * $a * $b)));
$text_angle = ceil($beta);