Find the cartesian X-Y-Z coordinates of cube: 3141592653589793238462
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Find the cartesian XYZ coordinates of cube "3141592653589793238462" using the method described at the url: cubicREMOVEpostcode.com (remove the word in capital letters, "REMOVE"). Please make sure you give the correct answer. I think the first python script have bugs for Y and Z. I think the value of X is correct. Please note that the XYZ coordinates are those of the cube centers. Please calculate it using your own logic.

Any bugs found in the first python script will be greatly appreciated.

Make sure you completely understand it and can help me out. Ask any questions you may have, please.

I'm not sure I understand. Why 21 million? The earth's circumference is larger than 21 million meters. Plus, the earth isn't flat, so this method of placing cubes on it does not unambiguously describe a location on the surface, much less into or away from the earth. I'll work on it as a math problem, though.
ProfessorG 4 months ago
@ProfessorG its radius is not though ;)
chesedo 4 months ago
The smallest cube that can contain the planet Earth has an edge of 12 742 000 meters since that is the diameter of Earth. If we used such a grid of cubes we would have 12742000×12742000×12742000 = 2.0688×10²¹ cubes. That means we would be using 22 digits. Since we need at least 22 digits we decided to use an edge of 21 million meters, that cubed will also have 22 digits, as that is a good compromise. If we used for instance 22 million meters for the edge of the grid of cubes we would neet 23 digits...
remotemass 4 months ago
X is calculated incorrectly in the provided script too. There's a small mistake there: the '-' operator is absent in the formula that should calculate negative X coordinates, so resulting X is always positive.
TheOsch 4 months ago
I will award "TheOsch" as he gave the solution that I better understand and that I will use on the website. But I will tip another $50 to "Chesedo" as well for his important contribution.
remotemass 4 months ago
awarded to TheOsch

Crowdsource coding tasks.

3 Solutions


I hacked together a brand new python implementation that takes an integer coordinate as command line input and outputs the x, y, and z coordinate as a tuple. The code is available here. Since the website didn't specify very clearly, I let (0, 0, 0) be coordinate 1, and let the x be the layer number, and y and z being the 2D coordinates on the plane. Obviously, my solution differs greatly from the python script posted on the website; I wasn't able to pick out any specific bugs, as I don't really understand the implementation. I can adjust my program to fit a more clear specification for 3D coordinates if you give one. My code should run in O(1) or constant time.

Oh, and I forgot to mention: my code outputs (7123792, -8402969, -9767162) for the example pi coordinate.
ProfessorG 4 months ago
Code fails at increments of 21 million squared, I'm going to go back and adjust accordingly (fixed and pushed)
ProfessorG 4 months ago
https://en.wikipedia.org/wiki/ECEF The X-coordinate of the center of all the 441000000000000 cubes in the first layer is: +0.5 meters. The X-coordinate of the center of all the cubes in the second layer is: -0.5 meters. The X-coordinate of the center of all the cubes in the third layer is: +1.5 meters. The X-coordinate of the center of all the cubes in the fourth layer is: -1.5 meters. The X-coordinate of the center of all the cubes in the fifth layer is: +2.5 meters. and so on and so forth... ... So I'm pretty sure that for cube 3141592653589793238462 => X=3561896.5 meters
remotemass 4 months ago
Yeah, I can't get behind this. Sorry. I can't see this as being useful for geolocation or practical to calculate in this form.
ProfessorG 4 months ago

In short my answer is [-8402969, 9767162, -3561896] [3561896.5, 9767162, -8402969] [3561896.5, -9767161.5, -8402969.5] [3561896.5, -8402969.5, -9767161.5]. The code and an explanation can be found on my repo.

https://en.wikipedia.org/wiki/ECEF The X-coordinate of the center of all the 441000000000000 cubes in the first layer is: +0.5 meters. The X-coordinate of the center of all the cubes in the second layer is: -0.5 meters. The X-coordinate of the center of all the cubes in the third layer is: +1.5 meters. The X-coordinate of the center of all the cubes in the fourth layer is: -1.5 meters. The X-coordinate of the center of all the cubes in the fifth layer is: +2.5 meters. and so on and so forth... ... So I'm pretty sure that for cube 3141592653589793238462 => X=3561896.5 meters
remotemass 4 months ago
I wonder why you call the layers "Z-Layers". All layers are parallel to the YZ_plane, so I'm not sure why you call them that. Maybe YZ-layers would make more sense...
remotemass 4 months ago
@remotemass orientation and x co-ordinates fixes. Can you please post the full co-ordinates for cube 1, 6 and 9? I have a feeling the z and y's are wrong too.
chesedo 4 months ago
Sure, that's easy: The XYZ coordinates in meters for the center of those cubes are: 1=(+0.5 , -0.5 , +0.5); 6=(+0.5 , -0.5 , +1.5); 9=(+0.5 , +1.5 , +0.5).
remotemass 4 months ago
Also, note that the Y-Z-coordinates of the center of cube 3141592653589793238462 have to be the same as the Y-Z-coordinates of the center of cube 381589793238462.
remotemass 4 months ago
@remotemass Z and Y calculations fixed. Yes, they will have the same Y and Z because they have the same offset / remainder. You can confirm if y and z are correct here - we seem to have our z and y swapped. Mine has z running from left-to-right (the way x normally does) and y from bottom-to-top (as normal)?
chesedo 4 months ago
Wait, z should also technically run from right-to-left? (That how it is in normal 3D apps)
chesedo 4 months ago
Z is the vertical axis... What do you mean right-to-left?
remotemass 4 months ago
I agree that the "square radius" that has our pi-cube is: 9 767 162. Do you agree that each of the four sides of that "square radius" will be two times that: 19 534 324? And that the first cube in that "square radius" is: 381 589 735 999 685 and that the last cube in that "square radius" is: 381 589 814 100 000 ?
remotemass 4 months ago
Oops, I mean projected on the first layer.
remotemass 4 months ago
"−9767161.5" is the value I get for Z-coordinate (in the vertical axis)... I wonder why you get that value for Y...
remotemass 4 months ago
I have the same "square radius" and side length. My first cube in "radius" 9 767 162 is also 381 589 735 999 685, but my last is 381 589 814 136 976. For "right-to-left" and the swapped Y and Z, I got my 3D space mixed up - will fix it later today...
chesedo 4 months ago
Fix made. It should be correct now.
chesedo 4 months ago
Winning solution

Let me try too.

X_meters:  3561896.5
Y_meters:  -8402969.5
Z_meters:  -9767161.5

The solution is based on a code you provided in the bounty description but I found a replacement for those long running calculations with cycles with several formulas that finally appeared to be absolutely trivial. Here it is: https://repl.it/@TheOsch/cubicpostcode

It seems your solution is correct except for Y. I tried different values and it seems that if you subtract one from Y you get the correct value for Y. Can you please check the code to see why your solution for Y has an offset of one? Note that the other solution provided makes me think that your Y is indeed offset by one. So we need your Y to be subtracted by one. Please check the code to see why. I will spend $50 in a tip, since I cannot award both. But both of you will earn $50. Nice that you noted the problem with X in my code
remotemass 4 months ago
Just a moment, I'll check what's wrong with Y and in which cases.
TheOsch 4 months ago
Sorry, I just thought that the cube number one has coordinates (0.5, 0.5, 0.5) instead of (0.5, -0.5, 0.5). Fixed.
TheOsch 4 months ago
Also, there seems to be a bug for when ( if cubeprojection > leftbottom). I'm getting the wrong values and with the wrong sign. Can you please check that also?
remotemass 4 months ago
Yes, I made a mistake in the formula, typed + instead of -. Fixed.
TheOsch 4 months ago
View Timeline