略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: atan

2024-12-22

atan

(PHP 4, PHP 5, PHP 7, PHP 8)

atan反正切

说明

atan(float $arg): float

返回 arg 的反正切值,单位是弧度。atan()tan() 的反函数,它的意思是在 atan() 范围里的每个值都是 a==tan(atan(a))

参数

arg

要处理的参数

返回值

arg 的反正切弧度。

参见

add a noteadd a note

User Contributed Notes 4 notes

up
12
Anonymous
7 years ago
Contrary to the current description, it should hold y == tan(atan(y)) for ALL  y.
However, x == atan(tan(x)) only holds for those x which are in the range of atan, which are those x with -pi/2 < x < pi/2.

Of course, those equalities are limited by precision. On my machine
tan(atan(1000)) returns 1000.0000000001.
atan(tan(0)) returns 0 (correct).
atan(tan(M_PI)) returns -1.2246467991474E-16 instead of 0.
up
2
darren_wheatley at hotmail dot com
18 years ago
Arc Tan curve manipulation.

I used this formula to help with increasing and then diminishing return for y given an increasing x for a game.

Ie: Food production (output) is y. Food research is x.

The more research you put into x the more you produce, however after a certain point you get less reward.

y = atan(x - pi()) + pi()/2;

The + pi()/2 moves it up the y axis so you'd add more if you want it to start higher.

The x - pi() moves it to the right so you'd minus more to move it more.

If you want stretched along the y axis change it to 2 * atan( ...... )

Dunno how useful it is... but it's there.

Daz
up
0
joelperr at kiwi-interactif dot com
16 years ago
to obtain the direction of the line, you are better to use the <? atan2((y2-y1)/(x2-x1)) ?> function, since the regular atan function will only return arguments in the half-plane, ie. if y2-y1 and x2-x1 are negative, atan will give you an angle measurement less than 90 degrees, while it really should be  between 180 and 270
up
-7
Ts.Saltan
6 years ago
arcctg function

function actg($arg){
    return acos($arg/(sqrt(1 + $arg * $arg)));
}

官方地址:https://www.php.net/manual/en/function.atan.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3