php deg2rad()是否等于mysql radians()

时间:2022-05-02 07:02:09

Are these functions the same? If not, what is an appropriate php equivalent to mysql's radians()

这些功能是否相同?如果没有,什么是适当的PHP相当于mysql的弧度()

2 个解决方案

#1


28  

Judging from their documentations (deg2rad, radians), they seem to do the same.

从他们的文件(deg2rad,弧度)来看,他们似乎也是如此。

And a quick verification on a simple test-case :

并快速验证一个简单的测试用例:

mysql> select radians(0), radians(45), radians(90);
+------------+-------------------+-----------------+
| radians(0) | radians(45)       | radians(90)     |
+------------+-------------------+-----------------+
|          0 | 0.785398163397448 | 1.5707963267949 |
+------------+-------------------+-----------------+
1 row in set (0,00 sec)

And, in PHP :

而且,在PHP中:

var_dump(deg2rad(0), deg2rad(45), deg2rad(90));

also gives :

还给出:

float 0
float 0.785398163397
float 1.57079632679

So, it seems they do quite the same...

所以,它们似乎完全一样......

#2


5  

Consulting the documentation:

咨询文档:

  • MySQL's RADIANS(x): returns the argument x, converted from degrees to radians.
  • MySQL的RADIANS(x):返回参数x,从度数转换为弧度。

  • PHP's DEG2RAD(): converts the number in degrees to the radian equivalent
  • PHP的DEG2RAD():将度数转换为弧度等价物

...so yes, they are equivalent.

......是的,它们是等价的。

Was there something more specific you were looking for?

你有什么更具体的东西吗?

#1


28  

Judging from their documentations (deg2rad, radians), they seem to do the same.

从他们的文件(deg2rad,弧度)来看,他们似乎也是如此。

And a quick verification on a simple test-case :

并快速验证一个简单的测试用例:

mysql> select radians(0), radians(45), radians(90);
+------------+-------------------+-----------------+
| radians(0) | radians(45)       | radians(90)     |
+------------+-------------------+-----------------+
|          0 | 0.785398163397448 | 1.5707963267949 |
+------------+-------------------+-----------------+
1 row in set (0,00 sec)

And, in PHP :

而且,在PHP中:

var_dump(deg2rad(0), deg2rad(45), deg2rad(90));

also gives :

还给出:

float 0
float 0.785398163397
float 1.57079632679

So, it seems they do quite the same...

所以,它们似乎完全一样......

#2


5  

Consulting the documentation:

咨询文档:

  • MySQL's RADIANS(x): returns the argument x, converted from degrees to radians.
  • MySQL的RADIANS(x):返回参数x,从度数转换为弧度。

  • PHP's DEG2RAD(): converts the number in degrees to the radian equivalent
  • PHP的DEG2RAD():将度数转换为弧度等价物

...so yes, they are equivalent.

......是的,它们是等价的。

Was there something more specific you were looking for?

你有什么更具体的东西吗?