These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

Calculating the Distance between System X and System Y

First post
Author
David Davaham
Deep Blue Logistics
#1 - 2016-11-15 08:13:54 UTC
Hola Amigos,

Okay so I am at the Headbashing the desk point and let me admit, that I am two years out of my algebra class and I DO NOT use math on a daily basis, so please accept this disclaimer ahead of time.

So I need to calculate the distance between to given points in space. In short, I am making a jump range calculator as a side project, but I cannot even get the correct product from my equation based on my reference which is EVEMaps. Is that a good reference?

Anyway, I code in PHP I have included my code before. Explanation below it.

Code

So to break this down I am pulling the X, Y, Z from the SDE for the two systems and then apply the equation in the formula from this Math StackExchange to the equation, but I am not getting the answer I want from the equation.

After some thinking I did notice that the coordinate was being stored in the database as coordinate e+X so I do multiple this out in the formula but i am still not getting an accurate number back. I am not sure how else to do this.

So my question is has anybody else ever need to calculate the distance between two systems? If so, how did you do it accurately?

Developer of EVEmail

erittainvarma
Fistful of Finns
#2 - 2016-11-15 08:57:31 UTC
I think you are just making things too complicated.

What I have used to calculate system distances:
$distance = sqrt(pow($x2-$x1,2)+pow($y2-$y1,2)+pow($z2-$z1,2))/9.4605284e15

All x,y,z values are straight from SDE database table mapDenormalize without any conversion. PHP appears to handle numbers with e correctly without any intervention.
David Davaham
Deep Blue Logistics
#3 - 2016-11-15 16:18:23 UTC
erittainvarma wrote:


$distance = sqrt(pow($x2-$x1,2)+pow($y2-$y1,2)+pow($z2-$z1,2))/9.4605284e15



What is the portion on the end. Where did that number came from? The "/9.5605284e15"

Developer of EVEmail

David Davaham
Deep Blue Logistics
#4 - 2016-11-15 16:48:42 UTC
David Davaham wrote:
erittainvarma wrote:


$distance = sqrt(pow($x2-$x1,2)+pow($y2-$y1,2)+pow($z2-$z1,2))/9.4605284e15



What is the portion on the end. Where did that number came from? The "/9.5605284e15"



Okay I really need to know what that number is. That number is what is making the script work and it is what i was missing last night. Please and Thank you. BTW, I had it done to this basic of a script before I got that long complicated gooply gob.

Developer of EVEmail

Steve Ronuken
Fuzzwork Enterprises
Vote Steve Ronuken for CSM
#5 - 2016-11-16 13:18:22 UTC  |  Edited by: Steve Ronuken
It's meters in a light year.

All the coordinates in Eve are stored in meters.

if you've not run into the notation, the e15 means multiply this by 1,000,000,000,000,000 (1 with 15 zeros after it)

Woo! CSM XI!

Fuzzwork Enterprises

Twitter: @fuzzysteve on Twitter