Users browsing this thread: 2 Guest(s)
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hyperjumping calculation (server part)
02-13-2010, 04:56 AM,
#1
Hyperjumping calculation (server part)
Hi all.

Lets talk about something good.
Theory about how hyperjump works in the server part.

You all must have notices that hyperjump looks like a giant parabola. But how all that works?.

MATH CONTENT ALERT !![Image: math%2520chalkboard.jpg]MATH CONTENT ALERT !!

First part, client request

Client sends a packet requesting hyperjump to server. That packets includes very specific content: initial point (Xi,Yi,Zi), the max height of the jump (Ymax) and the destination point (Xf, Yf, Zf).

Math requirements

The parabola used for hyperjump follows the squared X parabola, X^2.

Math expression for x^2 is y = a·x^2 + b·x + c

To solve this equation and get "a,b,c" values, you need to make 3 ecuations.
So lets take our 3 data from client's request.

First we forget about Z axis, we will handle it later.

Then we got the initial point, so (Xi,Yi), the final point (Xf,Yf) and the Y for another point (Ymax).

We lack of one value, but as we are working with 2D and theory says that the hip of the parabola is on the half of X axis, we can calculate is as: Xmed(Xf - Xi / 2)

Solving the equation

As we are not as good as machines, let them do the work for us!!

We got a system of 3 ecuations and 3 unknown values so:

Code:
Xi ·x^2   + Xi ·x + c = Yi
Xmed · x^2 + Xmed ·x + c = Ymax
Xf ·x^2   + Xf ·x + c = Yf

We will turn this into a matrix of double numbers and applicate Gauss-Jordan elimination, to solve it.

Gaussian Elimination (wikipedia), to know more

From this:

Code:
Xi ·x^2   + Xi ·x + c = Yi
Xmed · x^2 + Xmed ·x + c = Ymax
Xf ·x^2   + Xf ·x + c = Yf

To this (output from Gauss-Jordan):

Code:
a 0 0 value1
0 b 0 value2
0 0 c value3

Then we can assume that our hyperjump ecuation goes as:

y = value1 · x^2 + value2 · x + value3

With that expression, we can calculate any Y for any X that we want in the range that we used (Xi to Xf) with more or less precission.

Turning 2d into 3d theory

As you could see on real life, drawing on a paper, a line between 2 points is just the combination of their coords in the 2d plane, so mxo coords x and Z, could be treated as that.

Just knowing the initial and end X & Z values, we can do (Xf - Xi) / numPacketsNeeded and we will get the increment needed to go from one packet to other (same for Z axis).

This can be done on paper, try it.

So we calculate, lets say 50 divisions of the axis, for 50 packets and have, 50 X's and 50 z's.

Then we can calculate 50 Y's applicating the mxo formula to the X values.

Of course, drawing a line from one X Y Z point from that list to the next one in a big list of points, you create the ilusion of a curve from the eye view.

Splines (wikipedia), to know more.

Basicly, you can say that we throw a wire from initial point to the end point and then, took the middle and bring it up, creating a curve (same effect Tongue).

Testing theory on the battlefield

To test that it worked, i created a little 3d simulation where I could see the differences (draw 2 jumps) between a logged hyperjump and the simulation of coords.

Moved a ball leaving trail, firstly yellow, to pass through a logged hyperjump, starting from one building and landing at the street floor. Test was done using a 96 packets log extract.

Then, a second ball starting at same point, goes through 96 points but calculated dinamically using the parabola autocalculated through gauss-jordan, leaving a white trail behind.

This is a shot of the current project testing simulation (yeah its in 3d and you can zoom & rotate... über cool!)
[Image: testes.png]

As you see, the percentages are high, so we can say that we may have matched the right formula, but the end point, as second ball gets bit up than the logged one.
That can be fixed sending another landing packet with the right end coords, after the travelling.

Hope that you enjoy the tests Tongue.

Morph.
Reply
02-13-2010, 05:04 AM, (This post was last modified: 02-13-2010, 05:05 AM by Gerik.)
#2
RE: Hyperjumping calculation (server part)
(02-13-2010, 04:56 AM)Morpheus Wrote: MATH CONTENT ALERT !!

[Image: hs10eh.gif]
Reply
02-13-2010, 06:38 AM,
#3
RE: Hyperjumping calculation (server part)
if you exploded with this, wait for the "how to know what clients will receive my chat" explanation...

This was pretty simple, to be honest...
Reply
02-13-2010, 06:49 AM, (This post was last modified: 02-13-2010, 06:50 AM by Bayamos.)
#4
RE: Hyperjumping calculation (server part)
Dunno if you're using a library method or not, and I doubt it really matters since it's 3x3, but Gauss-Jordan is slower than Gauss/backsubstitution; I think it ends up introducing slightly less accurate results as well if you're using floating point. /shrug
[Image: 30nhcgn.png]
Reply
02-13-2010, 06:57 AM, (This post was last modified: 02-13-2010, 08:05 AM by Sixxth.)
#5
RE: Hyperjumping calculation (server part)
(02-13-2010, 06:38 AM)Morpheus Wrote: if you exploded with this, wait for the "how to know what clients will receive my chat" explanation...

This was pretty simple, to be honest...

So, got the math - Im an engineer FFS, so no issues there for me Smile

SO, will you use the existing animation? Actually, it seemed like there were a couple of animations depending on how high you were/how long the fall was, but whatever.

Would be awesome to have hyper jump back for sure - but how about little jumps over things, jumping off roofs etc? Same calculation I'm guessing? This is fascinating for me, prio to the MxOEmu, I always assumed that all the jumps were client side things, not server....
Reply
02-13-2010, 08:26 AM,
#6
RE: Hyperjumping calculation (server part)
Sexiest...post...EVER!
[Image: SigVII-1.gif]
Reply
02-13-2010, 09:15 AM,
#7
RE: Hyperjumping calculation (server part)
(02-13-2010, 06:49 AM)Bayamos Wrote: Dunno if you're using a library method or not, and I doubt it really matters since it's 3x3, but Gauss-Jordan is slower than Gauss/backsubstitution; I think it ends up introducing slightly less accurate results as well if you're using floating point. /shrug
Oh well i'm not a math boy, just tested with my knowledged, as matlab used Gauss/Jordan for my tests, then passed to python code to simulate in custom 3d. Did in Matlab, then checked if same a,b,c in pyth code.
Anyway, as long as you are able to pass and receive a matrix, code could work with the math function as a blackbox.
I would like to do benchmark with the one you mentioned though


(02-13-2010, 06:57 AM)Sixxth Wrote: So, got the math - Im an engineer FFS, so no issues there for me Smile

SO, will you use the existing animation? Actually, it seemed like there were a couple of animations depending on how high you were/how long the fall was, but whatever.

Would be awesome to have hyper jump back for sure - but how about little jumps over things, jumping off roofs etc? Same calculation I'm guessing? This is fascinating for me, prio to the MxOEmu, I always assumed that all the jumps were client side things, not server....
Client calculates if there is a building or crap like that. That's the red cross when you hyperjump or so targeting. I've never done it on real server but did on emu. Saw the flips and so.
Animations and that thing is what's sent by server, along the coords explained above.

Anyway, any question related or critics are welcome Tongue.

PS: at last! college maths serve for a purpose! XD
Reply
02-13-2010, 02:11 PM,
#8
RE: Hyperjumping calculation (server part)
now do the untargeted hyperjump !
Reply
02-13-2010, 04:15 PM,
#9
RE: Hyperjumping calculation (server part)
ctrl + space = random hell

But fascinating post Morph, I'm glad you can juggle those calculations.
"We die because the people are asleep...you will die because the people will awaken"-Carl Sandburg
[Image: testsignew.jpg]
Reply
02-13-2010, 04:29 PM,
#10
RE: Hyperjumping calculation (server part)
i rebound mine to T
so i can just HJ everywhere, very useful, much faster than running if theres a lot of obstacles in between (like DT)
Reply


Forum Jump: