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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top