Math 函数
在线手册:中文 英文
PHP手册

cos

(PHP 4, PHP 5)

cos余弦

说明

float cos ( float $arg )

cos() 返回参数 arg 的余弦值。参数 arg 的单位为弧度。

Example #1 cos()

<?php  

echo cos(M_PI); // -1  

?>

参见: acos()sin()tan()deg2rad()


Math 函数
在线手册:中文 英文
PHP手册
PHP手册 - N: 余弦

用户评论:

bruha at las wegos dot net (10-Aug-2008 03:45)

Another way to figure out a triangle (more efficient)

<?php
$a
= 10; // a
$b = 15; // b

$angle = 45// angle opposite side c

$c = (sqrt(pow($a, 2) + pow($b, 2) - $a * $b * cos(deg2rad($angle)) * 2));

// side c = 10.613894770933
?>

yes im good arent i?

joescuriosityshoppe at gmail dot com (13-Oct-2006 10:55)

Find the side of a triangle using two sides and an angle:
<?
$a = "10"; // length of side a
$b = "15"; // length of side b
$angle = "45";  // angle opposite side c

$c = (sqrt(pow($a, 2) + pow($b, 2) - $a * $b * cos(deg2rad($angle)) * 2));

// side c = 10.613894770933
?>

felipensp at gmail dot com (12-Mar-2006 01:29)

Convert degree to radianus, radianus to cos.

<?php

   
// Degree
   
$degree = 360;

   
// Convertion
   
print cos(deg2rad($degree));

?>