Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Mathematical Functions : atan

atan

Arc tangent (PHP 4, PHP 5)
float atan ( float arg )


Code Examples / Notes » atan

joelperr

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

jmartin

I looked for hours trying to come up with a formula to solve the direction that a line was heading (in degrees) when x1,y1 were the starting points, and x2,y2 are the ending points. Here is the equasion I was given, I hope this helps anyone in need of the same one.
$angle = rad2deg(atan2(($y2 - $y1), ($x2 - x1)));


darren_wheatley

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


Change Language


Follow Navioo On Twitter
abs
acos
acosh
asin
asinh
atan2
atan
atanh
base_convert
bindec
ceil
cos
cosh
decbin
dechex
decoct
deg2rad
exp
expm1
floor
fmod
getrandmax
hexdec
hypot
is_finite
is_infinite
is_nan
lcg_value
log10
log1p
log
max
min
mt_getrandmax
mt_rand
mt_srand
octdec
pi
pow
rad2deg
rand
round
sin
sinh
sqrt
srand
tan
tanh
eXTReMe Tracker