AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Arctangent (https://forums.alliedmods.net/showthread.php?t=10110)

twistedeuphoria 02-08-2005 14:39

Arctangent
 
Would someone please explain the arctangent function to me, I'm confused. floatatan takes an angle and a radix. Isn't arctangent supposed to go from a number to an angle? And what is a radix? floatatan2 takes x, y and a radix. I'm still confused...

Thanks in advance.

Johnny got his gun 02-08-2005 16:01

Well, I'm not really good at this stuff but have done some... things with it over the weeks.

Code:
        new Float:radians = floatatan(z/x, radian) // div by 0? :-P         new Float:degreeeeees = radians * g_ONEEIGHTYTHROUGHPI

floatatan returns radians. Which could be converted to degrees:
degrees = radians * 180 / pi

I think floatatan maybe can be set up to return degrees directly, although I think I had a problem with that for some reason.

TotalNoobScripter 02-08-2005 18:37

sry for this off-topic post, but for what purpose would u need arc's and tangets for? (Other than math class.)

twistedeuphoria 02-08-2005 19:28

Alright, I ended up using floatatan2 but I finally got it to work. I can get to polar coordinates with fairly good accuracy but I can't get back to rectangular nicely...

Code:
#include <amxmodx> #include <float> public plugin_init() {     register_plugin("Math Test","0.1","twistedeuphoria")     register_srvcmd("polar","to_polar")     register_srvcmd("rect","to_rectangular") } public to_polar() {     new xvalstr[3],yvalstr[3]     read_argv(1,xvalstr,2)     read_argv(2,yvalstr,2)     new Float:xval = floatstr(xvalstr)     new Float:yval = floatstr(yvalstr)     new Float:xsqr = floatpower(xval,2.0)     new Float:ysqr = floatpower(yval,2.0)     new Float:xysqtot = floatadd(xsqr,ysqr)     new Float:polarlen = floatsqroot(xysqtot)     new Float:polardeg = floatatan2(yval,xval,1)     server_print("LEN: %f DEG: %f",polarlen,polardeg)     return PLUGIN_HANDLED } public to_rectangular() {     new lenstr[21],degstr[21]     read_argv(1,lenstr,20)     read_argv(2,degstr,20)     new Float:len = floatstr(lenstr)     new Float:deg = floatstr(degstr)     new Float:xval = floatmul(len,floatcos(deg))     new Float:yval = floatmul(len,floatsin(deg))     server_print("X: %f Y: %f",xval,yval)     return PLUGIN_HANDLED }

This is what I have...any ideas as to the accuracy of the rectangular coordinates? Maybe variable accuracy? something else? I'll keep looking.

Johnny got his gun 02-09-2005 03:01

I use floatatan as an integral part in these plugins: Sentry guns and Enemy spotted
Feels wonderful to get a real use of those. :-)

twistedeuphoria 02-09-2005 12:29

You're no help! :D I suppose I'll just have to test how inaccurate it becomes in the real game <- LOL.


All times are GMT -4. The time now is 19:16.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.