# Plotting Earth's position with units

I'm trying to plot the Earth position with the Sun in the origin. I have two lists like this:

sun = {Subscript[M, S], e0sun = AstronomicalData["Sun", "Position"],v0sun = {0, 0}};
earth = {Subscript[M, T],e0earth = AstronomicalData["Earth", "Position"],v0earth = {0, 0}};


Where the first component is the mass, the second one is the position and the third one is the velocity(I will change this value later).And I have the function position like this:

position[{x1_, x2_, x3_}] = x2;


So the position function for earth and sun returns:

$$\{1.61307\times 10^{10} \text{m},1.46355\times 10^{11} \text{m},241710. \text{m}\}$$ $$\{0 \text{m},0 \text{m},0 \text{m}\}$$

When I try to plot both I do this:

S1 = Graphics3D[Point[position[earth]]];
S2 = Graphics3D[Point[position[sun]]];
Show[S1, S2, Axes -> True]


But I get an error because of the units, I think. I solved it doing:

S1 = Graphics3D[Point[{position[earth][[1, 1]], position[earth][[2, 1]],position[earth][[3, 1]]}]];


And the same for the sun, but I would like to find a better way with the units.

• I'm not sure about what you're trying to do with position[Array[x, Length[earth]]] = x, but it seems wrong to me Dec 15, 2014 at 19:59
• You are right, @belisarius, I already changed it. Dec 15, 2014 at 20:17

You could pick a unit for your coordinates and divide through by it:

S1 = Graphics3D[Point[position[earth]/Quantity[10^6, "Kilometers"]]];
S2 = Graphics3D[Point[position[sun]/Quantity[10^6, "Kilometers"]]];
Show[S1, S2,
Axes -> True,
AxesLabel -> Table[Quantity[HoldForm[10^6], "Kilometers"], {3}]] Or somewhat fancier:

ClearAll[powerForm];
Format[powerForm[quantity_Quantity, base_: 10]] ^:=
With[{p = Log[base, First@quantity]},
Quantity[HoldForm[base^p], Last@quantity]];

units = Quantity[10^6, "Kilometers"];
S1 = Graphics3D[Point[position[earth]/units]];
S2 = Graphics3D[Point[position[sun]/units]];
Show[S1, S2,
Axes -> True,
AxesLabel -> Table[powerForm@units, {3}]]