I'll see if I can figure out how to force python to use 32 bit floats and try to reproduce your results.
Confirmed here as well. I convert the distance to numpy's float32 datatype before rounding to 3 decimal places, and it works like a charm.
I'll see if I can figure out how to force python to use 32 bit floats and try to reproduce your results.
Confirmed here as well. I convert the distance to numpy's float32 datatype before rounding to 3 decimal places, and it works like a charm.
I have some catching up to do with your suggestions. But would it not mean every cube is very small. In your example each cube has an average of 6.33? But perhaps that IS the whole point. RTFA wolverine RTFA.
I wonder if you can grasp any of it. I just added some comments so I can later, too![]()
I got 25.21875, -20.90625, 25899.96875 for Sagittarius A*, using the screenshot + measure method.
My calculated coordinates were 0.00065, 0.0091 and 0.0015 away from the nearest 1/32 grid, respectively, so 2%, 29% and 5% error.
Edit: oops, previously posted coordinates weren't correct. I went the wrong way with the vertical (middle) one. These still don't match the distances that RedWizzard has though.
Ah-ha! At least for python, just converting the final distance to a float32 isn't enough. You have to convert to float32 before taking the sqrt (or norm, for numpy arrays), so that it presumably uses the float32 version of sqrt.
e.g.
coord1 = numpy.array(1.125, 2.25, 3.3125)
coord2 = numpy.array(5.96875, 6.6875, 7.4375)
numpy.linalg.norm((coord2 - coord1).astype(float32))
Using this to calculate the distance, my measured coordinates for Sagittarus A* fit RedWizzard's distances perfectly.
I haven't looked at the code, but are you using single-precision floats when performing the square root, as Athan had mentioned?
But LDS 1503 does not and it has 16 distances that match so I really don't think there is any way the calculated coordinates could be wrong.
It looks like you're using my stuff so take a look at bulklocate.html. Check the "include known calculated systems" box at the top and you'll be able to find those three systems in the table (click the column headers to sort). Alternatively you can enter the distances in entry.html to see how my algorithm reacts to the data.
So I guess the conclusion is that your coordinates look good and I think we've got the ED distance calculation properly nailed down now.
I did just that, but what should I check specifically? I am not saying your algorithm is incorrect. My idea was to present a completely new algorithm to calculate the distances, hopefully make it good enough to calculate results differently to verify them. While it could be used to generate distances (which it does to verify them) it is much more cpu/memory intensive than triangulation, so I made it as a verifier instead. So the algorithm is very different than others, therefore I see no way to use code/algorithms from others.
There is a lot of merit in having a completely different approach.
I'm not exactly sure what will help. Bulklocate should convince you that the calculated coordinates do in fact yield the distance numbers quoted (click on a system in the main table to get a list of reported and calculated distances). I guess then you'll need to try to track down which distances are causing your algorithm to fail to find a solution.
# warnings:
! LDS 1503 has 1 positions with 78.571% certainity, -51.78125,19.90625,-31.71875 included
! LP 229-17 has 1 positions with 75.000% certainity, -23.03125,9.03125,8.96875 included
! LHS 3297 has 1 positions with 88.889% certainity, -36.46875,22.68750,-16.53125 included
! WREDGUIA WH-Q B46-2 has 1 positions with 80.000% certainity, -132.68750,26.46875,-53.00000 included
What I have not realized so far was that it might not be enough to convert the input value for sqrtf to floating point; one must do that for the individual coordinates before squaring, to avoid 32-bit integer overflow. I just use 64-bit integers to avoid problems. (Perhaps someone pointed this out earlier, but I wasn't looking) Likely FD does just that, as it is the simplest thing to do, and it is ultimately incompatible with my solution (i.e. it will always report possibly incorrect coordinates).
I just thought I'd throw another idea out there, which might be helpful especially for stars that are far away, where we can't get a good set of reference distances to.
I took several screenshots in the galaxy map of a given star, and then using gimp's distance tool, I measured the number of pixels to the nearest grid lines, and was able to calculate the coordinate fairly accurately, accurate enough to get within 1/32 LY at least. The hardest is the vertical measurement, but if you position the camera so that it's exactly aligned with the plane that the grid forms, you can get a screenshot of the star with the above the lower plane and below the upper plane.
My implementation in c# has none of these rounding errors. I delete the xyz coords and then use 10 nearby systems and 5 long range systems to calculate, and then verify the distance against in game. I'm using 1/32 and the rounding system used is bankers rounding. Could your errors be from the rounding algorithm?
I finally finished my coordinate verifier tool (visit link to see how it works), and it also thinks that some coordinates are invalid:
LDS 1503
LHS 3297
WREDGUIA WH-Q B46-2
The tool thinks there is no valid coordinate for these systems, in other words, one or more of the distances must be incorrect. All other systems seems to be valid. I used this source.
So either the reported coordinates are incorrect (typo or rounding error), or there is something I didn't think of, and therefore not covered with a unit test in my tool.
//dist3 is the output from the distances api
function distcheck(){
var c1;
var c2;
var d1,dr1;
var d2,dr2;
var p = 1000;
$.each(dist3.distances, function (i1, v1) {
c1 = Vectorv.fromArray(v1.coord);
$.each(v1.refs, function (i2, v2) {
c2 = Vectorv.fromArray(v2.coord);
d1 = c1.subtract(c2).length();
d2 = Math.fround(d1);
dr1 = Math.round(d1 * p) / p;
dr2 = Math.round(d2 * p) / p;
if (dr1 != v2.dist) {
console.log(
v1.name + " [" + v1.coord + "]" +
"\n\t" + v2.name + " [" + v2.coord + "]" +
"\n\tFD dist: " + v2.dist.toFixed(3) +
"\n\tfloat64 d1: " + dr1.toFixed(3) + " <= Math.round(" + d1 + ")" + (dr1 == v2.dist ? " Correct" : " Wrong") +
"\n\tfloat32 d2: " + dr2.toFixed(3) + " <= Math.round(" + d2 + ")" + (dr2 == v2.dist ? " Correct" : " Wrong")
);
}
});
});
}
Alpha Cygni [-1405,46.09375,132.5]
Keries [-18.90625,27.21875,12.59375]
FD dist: 1391.399
float64 d1: 1391.398 <= Math.round(1391.3984541471666) Wrong
float32 d2: 1391.398 <= Math.round(1391.3984375) Wrong
Alpha Cygni [-1405,46.09375,132.5]
Tring [-125.375,9.5,-47.96875]
FD dist: 1292.807
float64 d1: 1292.806 <= Math.round(1292.8063323215217) Wrong
float32 d2: 1292.806 <= Math.round(1292.8062744140625) Wrong
Wredguia UR-Q b46-2 [-97.78125,56.875,-49.75]
HIP 91906 [-108.09375,57.1875,-33.59375]
FD dist: 19.170
float64 d1: 19.169 <= Math.round(19.169499903818565) Wrong
float32 d2: 19.170 <= Math.round(19.16950035095215) Correct
LFT 668 [-19.03125,25.65625,-24.21875]
Loga [-79.78125,36.53125,-42.0625]
FD dist: 64.243
float64 d1: 64.244 <= Math.round(64.24350192091416) Wrong
float32 d2: 64.243 <= Math.round(64.24349975585938) Correct
LHS 3297 [-36.46875,22.6875,-16.53125]
Haras [-118.75,14.40625,-21.40625]
FD dist: 82.840
float64 d1: 82.841 <= Math.round(82.8405023410952) Wrong
float32 d2: 82.840 <= Math.round(82.84049987792969) Correct
Wredguia WH-Q b46-2 [-132.6875,26.46875,-53]
Keries [-18.90625,27.21875,12.59375]
FD dist: 131.337
float64 d1: 131.336 <= Math.round(131.33649679592114) Wrong
float32 d2: 131.337 <= Math.round(131.3365020751953) Correct
But what about the first 2 for Alpha Cygni?
I don't recall reading about anyone having issue with that one (which could just be bad memory on my part ofc)
Anyone know whats up with those two distances?
Ie. neither float32 or float64 reports the same as ingame.
But what about the first 2 for Alpha Cygni?
I don't recall reading about anyone having issue with that one (which could just be bad memory on my part ofc)
Btw, you're printing the first set of co-ords for the second star in each set as well, which was slightly confusing for a moment.
I ran a super fast thrown together verifier thingy in JavaScript
Code:$.each(v1.refs, function (i2, v2) { c2 = Vectorv.fromArray(v2.coord); d1 = c1.subtract(c2).length();
I suspect we don't have the correct coordinate for this star yet. It's one of the ones that is rather far out, and hard to pin down using only trilateration. For these ones that are far out, my script isn't able to map out the candidate region quickly, so it aborts before finding/verifying the coordinate. I haven't tried letting it run longer for this particular star.
I'll see If I can do the screenshot + measure pixels method for it this evening, unless someone else wants to give it a go.