AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   some functions about math (https://forums.alliedmods.net/showthread.php?t=87669)

hzqst 03-15-2009 04:28

some functions about math
 
Quote:

stock Float:math_GetAngle(Float: x1, Float:y1, Float: x2, Float:y2){
new angle
floatatan2(y2 - y1, x2 - x1, angle)
return float(angle)
}
Quote:

stock Float:math_GetDistance (Float:x0, Float:y0, Float:x1, Float:y1){
return sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0))
}
Quote:

stock Float:math_PolarX12 (Float:x,Float:angle,Float:distance){
return (x+floatcos(angle)*distance)
}
Quote:

stock Float:math_PolarY12 (Float:y,Float:angle,Float:distance){
return (y+floatsin(angle)*distance)
}
are these functions correct?

I want to get 4 positions like this:
Quote:

X-X
-O-
X-X
-P-
X:the position which i need to get
O:where the player aims
P:player
Xs depend on where the player aims:

Quote:

-X
XOX
-X
-P

ConnorMcLeod 03-15-2009 05:01

Re: some functions about math
 
Have a look at xs.inc, there is usefull stocks.


All times are GMT -4. The time now is 08:52.

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