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!