Dirac
22710180
- Reaction score
- 147
I don't know if this exists yet, but it's very useful and self explanatory
How does the system work, and what's that TENDENCY var inside it?:
This system evaluates 2 close points between the point you're evaluating, the distance of this points to your point is the TENDENCY, then the system compares the Z of these 2 points, and creates an angle between them, this angle it's the point's inclination.
If you're not familiar with trigonometry i suggest you to use GetPointGravityAngle because it's very user friendly.
JASS:
library GetPointInclination /* v1.1.0
*/uses/*
*/ GetPointZ /* thehelper.net/forums/showthread.php/168825-GetPointZ
***********************************************************************
*
* function GetPointInclinationX takes real x,real y returns real
* function GetPointInclinationY takes real x,real y returns real
* - returns (in radians) angle between 0 and 90
* - If 0 then its flat, if 90 its a wall
*
* function GetPointcGravityAngle takes real x, real y returns real
* - Returns (in radians) angle between 0 and 360.
* - The angle points towards lower terrain level from the
* - desired location
*
* function IsPointInclined takes real x,real y returns boolean
*
**********************************************************************/
globals
private constant real TENDENCY=10
endglobals
function GetPointInclinationX takes real x,real y returns real
return Atan((GetPointZ(x+TENDENCY,y)-GetPointZ(x-TENDENCY,y))/(TENDENCY*2))
endfunction
function GetPointInclinationY takes real x,real y returns real
return Atan((GetPointZ(x,y+TENDENCY)-GetPointZ(x,y-TENDENCY))/(TENDENCY*2))
endfunction
function IsPointInclined takes real x,real y returns boolean
return not(0==GetPointInclinationX(x,y)) or not(0==GetPointInclinationY(x,y))
endfunction
function GetPointGravityAngle takes real x, real y returns real
return Atan2(-Sin(GetPointInclinationY(x,y)),-Sin(GetPointInclinationX(x,y)))
endfunction
endlibrary
How does the system work, and what's that TENDENCY var inside it?:
This system evaluates 2 close points between the point you're evaluating, the distance of this points to your point is the TENDENCY, then the system compares the Z of these 2 points, and creates an angle between them, this angle it's the point's inclination.
If you're not familiar with trigonometry i suggest you to use GetPointGravityAngle because it's very user friendly.