Snippet GetPointInclination

Dirac

22710180
Reaction score
147
I don't know if this exists yet, but it's very useful and self explanatory
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.
 

luorax

Invasion in Duskwood
Reaction score
67
Actually you're leaking two location handle in both GetLocInclinationX and GetLocInclinationY functions.

Use a global location and [ljass]MoveLocation()[/ljass].
 

Dirac

22710180
Reaction score
147
Ty luorax, i never ever use locations, but in order to use getlocZ i must. Code updated
 

Dirac

22710180
Reaction score
147
In order to explain how does TENDENCY affects the code i must explain you how does the system works. But ok.

IMO TENDENCY should never be changed
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Code:
GetLocInclinationX(real x,real y)
    // returns (in radians) angle between 0 and 90
    // -If 0 then its flat, if 90 its a wall

If you plug for r (the height of the first point, say 3) and for l (the height of the second point, say 8) then
the atan(3 - 8) / 20 is not an angle between (0 and 90) because it's negative.

Shouldn't you calculate the angle between the two heights with abs(atan2(r - l, 10)) to get an angle between 0 and 90 in radians?

Why is the angle between the two heights calcualted with TENDENCY * 2? (atan(r - l, TENDENCY * 2)?

And what do you mean by "algorithmic concepts" in the "In order to understand GetLocGravityAngle you must know some algorithmic concepts"? Can you describe them?
 

Dirac

22710180
Reaction score
147
If you plug for r (the height of the first point, say 3) and for l (the height of the second point, say 8) then
the atan(3 - 8) / 20 is not an angle between (0 and 90) because it's negative.

Shouldn't you calculate the angle between the two heights with abs(atan2(r - l, 10)) to get an angle between 0 and 90 in radians?
this is correct, it returns an angle between -90 and 90, i just fixed that in the tooltip
Why is the angle between the two heights calcualted with TENDENCY * 2? (atan(r - l, TENDENCY * 2)?
I don't see why i should explain this, the system works fine, but ok
TENDENCY*2 is equal to the distance between the two points (left and right) or (up and down) from each other.
And what do you mean by "algorithmic concepts" in the "In order to understand GetLocGravityAngle you must know some algorithmic concepts"? Can you describe them?
Again i don't see a reason of why i should explain this, i already explained how TENDENCY works and how you should manipulate, anything else works fine according to your values
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
@Dirac: "TENDENCY*2 is equal to the distance between the two points (left and right) or (up and down) from each other."
A: haha yeah well it took me some time to heat up =)

@Dirac: "i don't see a reason of why i should explain this (algorithmic concepts), i already explained how TENDENCY works and how you should manipulate, anything else works fine according to your values "
A: Why wouldn't you explain how your own script works (given that you upload them for other users to use). Describing them with vague terms like "algorithmic concepts" doesn't really help (I'm sure you would agree). Deducting from the function's name GetLocGravityAngle,
I far as I know the acceleration due to gravity is always towards the center of the earth (so always 90 degrees/down [or 270 degrees depending how you look at it]), so does that mean that the angle this function returns is always 90 deg? (I think not.)

@Dirac: " -The angle points towards lower terrain *
* level from the desired location"
A: I really don't know what you mean with that. Can you give an example?

I am not saying that your script doesn't work, I just don't know how to use it (even after reading your description).
So that's why I'm "annoying" you to describe it in more familiar terms (give some examples etc.) / layman's terms.

Edit: wait does the GetLocationGravityAngle == GetLocInclination? (It seams like it). If so then why name it "GravityAngle"?
 

Dirac

22710180
Reaction score
147
wait does the GetLocationGravityAngle == GetLocInclination? (It seams like it). If so then why name it "GravityAngle"?
No.
Gravity Angle is a tool i added to return an angle that always points towards the lowest area of a terrain, suppose you'r unit is on a ramp, the angle returned would point towards the ramp's start at the lower terrain.

GetLocInclination works in a total different manner, it points an angle in a Z parameter, this angle points the difference between a flat floor (0 degrees) and the current inclination level, if your ramp has low elevation it should return something between 20 and 30 degrees, depending on the inclination of the ramp, if it's very steep then the angle would be around 50 and 70 degrees, remember always according the the ramp's inclination

EDIT: the explanations written above are not "how my system works" but most likely "what my system does". Explaining how it works is almost futile unless it aims for efficiency issues, and beyond luorax's correction i don't think there should be any
 

NoobImbaPro

You can change this now in User CP.
Reaction score
60
That's a very good idea, but who will use it?

You have to know some advanced physics :D
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
I asked you to explain what you meant by "algorithmic concepts" that's all.

So if "Gravity Angle is an angle that always points towards the lowest area of a terrain, suppose you'r unit is on a ramp, the angle returned would point towards the ramp's start at the lower terrain." doesn't hat mean that the "Gravity Angle" = Elevation Angle + 180? 180 deg = PI of course.
 

Dirac

22710180
Reaction score
147
doesn't hat mean that the "Gravity Angle" = Elevation Angle + 180? 180 deg = PI of course.
No. the gravity angle doesn't point to the ground, it points towards lowest place nearby. And i totally didn't get what you were trying to say

(side note) i didn't mean algorithmic, but trigonometric, sorry for the confusion

EDIT: didn't see your reply there.
That's a very good idea, but who will use it?

You have to know some advanced physics :D
actually no, maybe the inclination angles are complicated to use, but the Gravity angle is actually very user friendly, if you want a unit to move faster when walking downcliff, then move it periodically towards the GravityAngle.
 

tooltiperror

Super Moderator
Reaction score
231
Very nice. Periodically people need things like these, it's kind of like wanting a XOR or a Logarithm.

Approved.
 

Dirac

22710180
Reaction score
147
Updated to v1.1.0
-Change the API
-Uses GetPointZ now
-No locals.

I would like to change the title to GetPointInclination
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/
  • The Helper The Helper:
    Here is another comfort food favorite - Million Dollar Casserole - https://www.thehelper.net/threads/recipe-million-dollar-casserole.193614/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top