Discussion What is the most efficient way to crowdsource the 3D system coordinates

wolverine2710

Tutorial & Guide Writer
Could someone elaborate on the 1/32 rule?

Do you just need to multiply the inputted distances by 32 and then divide the coordinates by 32?

The 1/32 LY grid has been discussed quite a bit here. There are multipe ways to round of to a (or the nearest) 1/32 grid. In Excel: =ROUND(D18*32;0)/32 (TunaMage spreadsheet). RedWizard in his code also does rounding. Perhaps that gives you an idea of a possible implementation. Hope this helps a bit.
 

wolverine2710

Tutorial & Guide Writer
Yes, I can add a decimal places option quite easily. I have only tested 3 of JesusFreke's systems so far (see above) they are not bad, but not spot-on (max error was 0.4 ly). I will try to do more tonight.

3,4,5 decimals as a command line parameter would be great. Not sure what you mean with " I will try to do more tonight.". If you mean checking for validity its perhaps better just to recalculate them. JesusFreke has a spreadsheet with all the distance he took. You can find it here. You can simply change the ref points in the entry.html form of RW. Done that and that works. Then its just a matter of copy/pasting his numbers into RW's tool and we have accurate coords. JesusFreke has made enough measurement to ensure that.
I apologize if the above is exactly what you wanted to do ;-)

If not. Perhaps someone is willing to do that?
 

wolverine2710

Tutorial & Guide Writer
Well, I would like to say thanks Wolverine for all the effort you are putting into pulling this all together.

I'm not sure if I speak for the others in this thread, but I'm finding the challenge of working through the difficulty of getting the coords reliably together quite fun. It definitely adds a new dimension to the game for me, and ED wouldn't be ED without a bit of a challenge :D

Your welcome.
Commanders, your are typing faster then I can reply ;-)

Indeed in this thread I've read more commanders saying they are enjoying the technical challenge. A challenge which has defeated it seems...
 

wolverine2710

Tutorial & Guide Writer
I believe the result that comes back from Snuble's trilateration function is rounded to 5 decimal places.

To be honest I'm not sure why I used 6 decimal places on the averaged value. ;)

I can't say I really understand all this 1/32 talk. Are you saying it would be better to use 3 decimal places from both the trilateration function and the final averaged output?

I'm not the expert on trilateration. The Galaxy maps gives us 3 decimals we can input in your or RW's or wahtever tool created by a commander who dedicated his/her time for this. The data (output) of wtbw and Michael Brookes is in 5 decimals and its rounded to a 1/32LY grid. Thats all I can say about the matter.
 
3,4,5 decimals as a command line parameter would be great. Not sure what you mean with " I will try to do more tonight.". If you mean checking for validity its perhaps better just to recalculate them. JesusFreke has a spreadsheet with all the distance he took. You can find it here. You can simply change the ref points in the entry.html form of RW. Done that and that works. Then its just a matter of copy/pasting his numbers into RW's tool and we have accurate coords. JesusFreke has made enough measurement to ensure that.
I apologize if the above is exactly what you wanted to do ;-)

If not. Perhaps someone is willing to do that?
I meant I would check a few more in game. As there is a slight overlap with Harbringer's data I thought I would compare the two. I don't fancy doing any recalculations, already spending more time in PyCharm than ED, which is not good!
 

Harbinger

Volunteer Moderator
The 1/32 LY grid has been discussed quite a bit here. There are multipe ways to round of to a (or the nearest) 1/32 grid. In Excel: =ROUND(D18*32;0)/32 (TunaMage spreadsheet). RedWizard in his code also does rounding. Perhaps that gives you an idea of a possible implementation. Hope this helps a bit.

OK I've updated Snuble's trilateration3d() function to this to take your 1/32 excel example into account:
Code:
function trilateration3d($p1,$p2,$p3,$p4){
        $ex = vector_unit(vector_diff($p2, $p1));
        $i = vector_dot_product($ex, vector_diff($p3, $p1));
        $ey = vector_unit(vector_diff(vector_diff($p3, $p1), vector_multiply($ex, $i)));
        $ez = vector_cross($ex,$ey);
        $d = vector_length($p2, $p1);
        $r1 = $p1[3]; $r2 = $p2[3]; $r3 = $p3[3]; $r4 = $p4[3];
        if($d - $r1 >= $r2 || $r2 >= $d + $r1){
                return array();
        }
        $j = vector_dot_product($ey, vector_diff($p3, $p1));
        $x = (($r1*$r1) - ($r2*$r2) + ($d*$d)) / (2*$d);
        $y = ((($r1*$r1) - ($r3*$r3) + ($i*$i) + ($j*$j)) / (2*$j)) - (($i*$x) / $j);
        $z = $r1*$r1 - $x*$x - $y*$y;

        if($z < 0){
                return array();
        }
        $z1 = sqrt($z);
        $z2 = $z1 * -1;

        $result1 = $p1;
        $result1 = vector_sum($result1, vector_multiply($ex, $x));
        $result1 = vector_sum($result1, vector_multiply($ey, $y));
        $result1 = vector_sum($result1, vector_multiply($ez, $z1));
        $result2 = $p1;
        $result2 = vector_sum($result2, vector_multiply($ex, $x));
        $result2 = vector_sum($result2, vector_multiply($ey, $y));
        $result2 = vector_sum($result2, vector_multiply($ez, $z2));

        $r1 = vector_length($p4, $result1);
        $r2 = vector_length($p4, $result2);
        $t1 = $r1 - $r4;
        $t2 = $r2 - $r4;
        $coords = array();
        if(abs($t1) < abs($t2)){
                $coords = array((round(($result1[0]*32),0)/32), (round(($result1[1]*32),0)/32), (round(($result1[2]*32),0)/32));
        }
        else{
                $coords = array((round(($result2[0]*32),0)/32), (round(($result2[1]*32),0)/32), (round(($result2[2]*32),0)/32));
        }
        return $coords;
}

And I now get the exact same result for every single permutation, in the case of LP 378-541 (1.1875, 20.71875, 2.34375).

Looks like I don't need to average anything anymore. :D
 

wolverine2710

Tutorial & Guide Writer
I meant I would check a few more in game. As there is a slight overlap with Harbringer's data I thought I would compare the two. I don't fancy doing any recalculations, already spending more time in PyCharm than ED, which is not good!

I understand your feelings. I'm spending also far more time here in this thread and checking things then playing ED. In fact in the last four days only started ED to get distances. NOT fired a single shot, nor did trading/BBS-ing. BUT we are getting somewhere. Thanks btw for your work on TD, very much appreciated. Want to do some stuff in Python and TD to but it has to wait. Java (former Perl) guy , not a python guy, but looking forward to learn something new. Python seems to be a fine language, which was created by a fellow Dutchie!!
 
Could someone elaborate on the 1/32 rule?

Do you just need to multiply the inputted distances by 32 and then divide the coordinates by 32?

The co-ordinates appear to be to an accuracy of 1/32ly, both in Michael Brookes' spreadsheet and in-game (confirmed by using the spreadsheet to calculate distances from various stars to the one I was at, and checking the calculated distance was the same as the in-game displayed one to a reasonable margin of error, see this post).

So, after calculating any co-ordinates ideally you would round them to the nearest 1/32 value. Note this is NOT just "multiply by 32, truncate, divide by 32" as you'll incorrectly round down. You want to:

1) Add 1/64.
2) Multiply by 32.
3) Truncate to integer.
4) Divide by 32.

i.e. your usual 'half rounding', but for binary at the 1/32 level.
 
3,4,5 decimals as a command line parameter would be great.


Code:
>trade.py local --ly 10 --dp 6 hermitage

Local systems to HERMITAGE within 10.0 ly.
------------------------------------------
 4.291161 LHS 3281
 5.093846 WOLF 654
 7.196801 LP 275-68
 7.709129 TILIAN
 9.480758 LHS 3262
 9.773859 ZETA HERCULIS
 9.917876 LHS 6309
 

wolverine2710

Tutorial & Guide Writer
Code:
>trade.py local --ly 10 --dp 6 hermitage

Local systems to HERMITAGE within 10.0 ly.
------------------------------------------
 4.291161 LHS 3281
 5.093846 WOLF 654
 7.196801 LP 275-68
 7.709129 TILIAN
 9.480758 LHS 3262
 9.773859 ZETA HERCULIS
 9.917876 LHS 6309

Nice!!
 

wolverine2710

Tutorial & Guide Writer
The co-ordinates appear to be to an accuracy of 1/32ly, both in Michael Brookes' spreadsheet and in-game (confirmed by using the spreadsheet to calculate distances from various stars to the one I was at, and checking the calculated distance was the same as the in-game displayed one to a reasonable margin of error, see this post).

So, after calculating any co-ordinates ideally you would round them to the nearest 1/32 value. Note this is NOT just "multiply by 32, truncate, divide by 32" as you'll incorrectly round down. You want to:

1) Add 1/64.
2) Multiply by 32.
3) Truncate to integer.
4) Divide by 32.

i.e. your usual 'half rounding', but for binary at the 1/32 level.

Does this mean that the spreadsheet by Tunamage is not totally optimal?
Also curious how RW does it - not looked at the code (yet).
 

wolverine2710

Tutorial & Guide Writer
EDIT: By the way I've been doing some work on the script I've been using. It now stores the info and allows users to view the data in either formatted array or JSON format for easy import into other tools:

LP 378-541 Test (Formatted Array)
LP 378-541 Test (JSON output)

Looks great for anyone interested in your permutations and output. Makes parsing a snap.

Would you be interested in taking this ONE step further. That way we can have everything automized and start the great data crowd sourcing effort. It doesn't have to be an all singing all dancing solution, just functional.

To keep things simple lets concentrate on the two web-based solutions : yours and RW's. Haven't tested yours yet. In both cases users can input distances to at least 4 distances and then coords are calculated. In both solutions there is no feeback if a system has already been entered. Neither is it possible to get an updated list of stations with their coords. You already are able to provide in JSON the end result.

Could the following not give a simple, but sufficient and complete solution?
When a commander uses your webpage to enter distances, you calculate the coords and then add them to a system-coord.json file. You could use that file to tell a cmdr that a system he's inputtin distances for already coords. RW's tool when started reads your json file using an url. RW's tool could use your json file to determine if a statiion has already been entered. When a cmdr has calculated coord with RW's tool he hits the publish button. The coords in json format are uploaded to your website and added to the system-coord.json file. This can be as simple as calling an url and as parameters provide the json coords. What HAS to be done is to establish a common json format which you and RW can use. It can for example also be used by Shrudds website - where cmdr als can enter distances and a coord is calculated. I've simplified things but I hope the essence is clear. No need for a real web-api, just a simple upload and an url where the system-coord.json file can be downloaded from.

RW, HBm shrudd, others. Do you think this is whats needed? Is this viable?
 
Last edited:

Harbinger

Volunteer Moderator
Looks great for anyone interested in your permutations and output. Makes parsing a snap.

Would you be interested in taking this ONE step further. That way we can have everything automized and start the great data crowd sourcing effort. It doesn't have to be an all singing all dancing solution, just functional.

To keep things simple lets concentrate on the two web-based solutions : yours and RW's. Haven't tested yours yet. In both cases users can input distances to at least 4 distances and then coords are calculated. In both solutions there is no feeback if a system has already been entered. Neither is it possible to get an updated list of stations with their coords. You already are able to provide in JSON the end result.

Could the following not give a simple, but sufficient and complete solution?
When a commander uses your webpage to enter distances, you calculate the coords and then add them to a system-coord.json file. You could use that file to tell a cmdr that a system he's inputtin distances for already coords. RW's tool when started reads your json file using an url. RW's tool could use your json file to determine if a statiion has already been entered. When a cmdr has calculated coord with RW's tool he hits the publish button. The coords in json format are uploaded to your website and added to the system-coord.json file. This can be as simple as calling an url and as parameters provide the json coords. What HAS to be done is to establish a common json format which you and RW can use. It can for example also be used by Shrudds website - where cmdr als can enter distances and a coord is calculated. I've simplified things but I hope the essence is clear. No need for a real web-api, just a simple upload and an url where the system-coord.json file can be downloaded from.

RW, HBm shrudd, others. Do you think this is whats needed? Is this viable?


Sure I could add checking to see if a system has been added, parse other json outputs, edit files etc.

FWIW I tested the math Athan posted and it changed the position of LP 378-541 from (1.1875, 20.71875, 2.34375) to (1.1875, 21.03125, 2.375). Not sure which is the better result but I've reverted it back to the half-rounding solution in the interim as that's what everyone seems to be using.
 

wolverine2710

Tutorial & Guide Writer
Sure I could add checking to see if a system has been added, parse other json outputs, edit files etc.

FWIW I tested the math Athan posted and it changed the position of LP 378-541 from (1.1875, 20.71875, 2.34375) to (1.1875, 21.03125, 2.375). Not sure which is the better result but I've reverted it back to the half-rounding solution in the interim as that's what everyone seems to be using.

Sounds great. Perhaps you can send RedWizard a PM to discuss things further or you can discuss it here. I have of course ideas but I will try very hard to be silent - this time ;-).
A 'publish' button means his tool does not need to be hosted any where, very little has to be changed etc. At least that seems to be the case. BUT we still end up with a solution where the admin is automized and multiple authors can share info, great. Keep me posted....

Wrt rounding etc. I don't have the math skills for that. But Athan in post #292 said that RW and TM are basically doing the same he suggested. Not sure why you are getting different results.... Perhaps Athan, Rw or TM can explain what is meant and what they are doing and why your results are different. If you multiply your end result by 32 it SHOULD result in an integer - as in 0 decimals. Have your tried that?

I've realy lost count of the number of post I made this day but it all feels very positive.
 
Last edited:
Sure I could add checking to see if a system has been added, parse other json outputs, edit files etc.

FWIW I tested the math Athan posted and it changed the position of LP 378-541 from (1.1875, 20.71875, 2.34375) to (1.1875, 21.03125, 2.375). Not sure which is the better result but I've reverted it back to the half-rounding solution in the interim as that's what everyone seems to be using.

You're only doing the rounding with the end co-ordinates, yes? Because the above implies you're doing it somewhere in the middle as well.

( 20.71875 + 1/64 ) * 32 = 663.5, truncated 663, 663 / 32 = 20.7187500000 (i.e. the number was already rounded).

Likewise: ( 2.34375 + 1/64 ) * 32 = 75.5, 75 / 32 = 2.34375
 

Harbinger

Volunteer Moderator
You're only doing the rounding with the end co-ordinates, yes? Because the above implies you're doing it somewhere in the middle as well.

( 20.71875 + 1/64 ) * 32 = 663.5, truncated 663, 663 / 32 = 20.7187500000 (i.e. the number was already rounded).

Likewise: ( 2.34375 + 1/64 ) * 32 = 75.5, 75 / 32 = 2.34375

I've looked over my code and made an error. :eek:

After fixing the error your alternate method gives the same result as the previous method.

Changed php function:
Code:
function trilateration3d($p1,$p2,$p3,$p4){
        $ex = vector_unit(vector_diff($p2, $p1));
        $i = vector_dot_product($ex, vector_diff($p3, $p1));
        $ey = vector_unit(vector_diff(vector_diff($p3, $p1), vector_multiply($ex, $i)));
        $ez = vector_cross($ex,$ey);
        $d = vector_length($p2, $p1);
        $r1 = $p1[3]; $r2 = $p2[3]; $r3 = $p3[3]; $r4 = $p4[3];
        if($d - $r1 >= $r2 || $r2 >= $d + $r1){
                return array();
        }
        $j = vector_dot_product($ey, vector_diff($p3, $p1));
        $x = (($r1*$r1) - ($r2*$r2) + ($d*$d)) / (2*$d);
        $y = ((($r1*$r1) - ($r3*$r3) + ($i*$i) + ($j*$j)) / (2*$j)) - (($i*$x) / $j);
        $z = $r1*$r1 - $x*$x - $y*$y;

        if($z < 0){
                return array();
        }
        $z1 = sqrt($z);
        $z2 = $z1 * -1;

        $result1 = $p1;
        $result1 = vector_sum($result1, vector_multiply($ex, $x));
        $result1 = vector_sum($result1, vector_multiply($ey, $y));
        $result1 = vector_sum($result1, vector_multiply($ez, $z1));
        $result2 = $p1;
        $result2 = vector_sum($result2, vector_multiply($ex, $x));
        $result2 = vector_sum($result2, vector_multiply($ey, $y));
        $result2 = vector_sum($result2, vector_multiply($ez, $z2));

        $r1 = vector_length($p4, $result1);
        $r2 = vector_length($p4, $result2);
        $t1 = $r1 - $r4;
        $t2 = $r2 - $r4;
        $coords = array();

        if(abs($t1) < abs($t2)){

                $result1[0]+=(1/64);
                $result1[0]*=32;
                $result1[0]=floor($result1[0]);
                $result1[0]/=32;

                $result1[1]+=(1/64);
                $result1[1]*=32;
                $result1[1]=floor($result1[1]);
                $result1[1]/=32;

                $result1[2]+=(1/64);
                $result1[2]*=32;
                $result1[2]=floor($result1[2]);
                $result1[2]/=32;

                $coords = array($result1[0], $result1[1], $result1[2]);
        }
        else{

                $result2[0]+=(1/64);
                $result2[0]*=32;
                $result2[0]=floor($result2[0]);
                $result2[0]/=32;

                $result2[1]+=(1/64);
                $result2[1]*=32;
                $result2[1]=floor($result2[1]);
                $result2[1]/=32;

                $result2[2]+=(1/64);
                $result2[2]*=32;
                $result2[2]=floor($result2[2]);
                $result2[2]/=32;

                $coords = array($result2[0], $result2[1], $result2[2]);
        }

        return $coords;
}
 
Back
Top Bottom