Snippet Movement Calculation

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
/////////////////////////////////////////////////////////////////////////////////////////////
//  Functions :
//
//  GetDisplacementLoc(locationA,locationB) -> real(Distance Between 2 points)
//  GetDisplacement(x1,y1,x2,y2) -> real(Distance Between 2 points)
//  GetVelocityLoc(locationA,locationB,time) -> real(X range/second)
//  GetVelocity(x1,y1,x2,y2,time) -> real(X range/second)
//  GetAcceleration(final velocity, initial velocity, time) -> range/second-1
//
//  Recommended using XY since it is faster.
//  P/S : I found the the unit does not move unitformly in warcraft engine.
//        They have acceleration and decceleration
/////////////////////////////////////////////////////////////////////////////////////////////
library MovementCalculating

    function GetDisplacementLoc takes location locA, location locB returns real
        local real locAX = GetLocationX(locA)
        local real locAY = GetLocationY(locA)
        local real locBX = GetLocationX(locB)
        local real locBY = GetLocationY(locB) 
        return SquareRoot((locBX - locAX) * (locBX - locAX) + (locBY - locAY) * (locBY - locAY))
        //Return distance between 2 points
    endfunction

    function GetDisplacement takes real x1, real y1, real x2, real y2 returns real 
        return SquareRoot((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
        //Return distance between 2 points
    endfunction
    
    function GetVelocityLoc takes location locA, location locB, real time returns real
        return GetDisplacementLoc(locA, locB)/time
        //Return Velocity
    endfunction
    
    function GetVelocity takes real x1, real y1, real x2, real y2, real time returns real 
        return GetDisplacement(x1, y1, x2, y2)/time
        //Return Velocity
    endfunction
    
    function GetAcceleration takes real v, real u, real time returns real
        //V = Final Velocity
        //U = Initial Velocity
        return (v-u)/time
        //Return acceleration
        //If returned value is negative, then it is decceleration
        //If returned value is 0, then it is neither accelerates or decelerates but is constant velocity
    endfunction
   
   
endlibrary


Hmm, i think it is useful in calculating APM(s).
I have attached a map here for u guys to test it! :D
 

Trollvottel

never aging title
Reaction score
262
Looks kind of useless to me. Every 12 year old child would be able to do this (if it knows jass and is not too stupid).

Also:
JASS:
 function GetDisplacementLoc takes location locA, location locB returns real
        local real locAX = GetLocationX(locA)
        local real locAY = GetLocationY(locA)
        local real locBX = GetLocationX(locB)
        local real locBY = GetLocationY(locB) 
        return SquareRoot((locBX - locAX) * (locBX - locAX) + (locBY - locAY) * (locBY - locAY))
        //Return distance between 2 points
    endfunction


this looks like crap to me, its like the DistanceBetweenPoints BJ-function but worse, since it uses more calculations and more variables.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
So I recommended use XY. The Location is slower but I made it also for location users easy to use it.
 

Trollvottel

never aging title
Reaction score
262
But why do you even implement a function if Blizzard provides a better version of it?
 

_whelp

New Member
Reaction score
54
How do I use this?

According to Trollvottel, I wouldn't understand this because I'm ten.
 

_whelp

New Member
Reaction score
54
Can't you just write down the formula?
It's pretty easy to remember an write anyways.
 

Flare

Stops copies me!
Reaction score
662
How do I use this?

According to Trollvottel, I wouldn't understand this because I'm ten.
He said 12, not 10 (although you might do this sort of math at that age anyway) :p

Overall, it's just basic math and not hard for anyone to do. The location one is pointless since the BJ function already exists and most people who use JASS would be using coordinates anyway
 

wraithseeker

Tired.
Reaction score
122
JASS:
function GetDisplacement takes real x1, real y1, real x2, real y2 returns real 
        return SquareRoot((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
        //Return distance between 2 points
    endfunction


JASS:
 return SquareRoot((locBX - locAX) * (locBX - locAX) + (locBY - locAY) * (locBY - locAY))


Identical and totally the same.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Is this faster?

JASS:
function GetDisplacement takes real x1, real y1, real x2, real y2 returns real 
        return x1*x1 -2*x1*x2 +x2*x2 + y1*y1-2*y1*y2+y2*y2
endfunction


Any ideas?
 

Trollvottel

never aging title
Reaction score
262
@Flare

It was

"wouldn't",

not "would".

And i didnt say 10 year olds couldnt understand. but have you done linear functions or pythagoras? (This system is only pythagoras and linear functions)

Is this faster?

JASS:
function GetDisplacement takes real x1, real y1, real x2, real y2 returns real 
        return x1*x1 -2*x1*x2 +x2*x2 + y1*y1-2*y1*y2+y2*y2
endfunction


Any ideas?

Does it even work? Looks weird to me, which formula did you use to make this?
 
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

      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