Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4982 > unrolled thread
| Started by | Peter Sisak <p-kun80@hotmail.com> |
|---|---|
| First post | 2011-09-15 08:53 +0000 |
| Last post | 2011-09-16 09:55 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
"Traveling salesman on a hemisphere" problem Peter Sisak <p-kun80@hotmail.com> - 2011-09-15 08:53 +0000
Re: "Traveling salesman on a hemisphere" problem Olaf <olaf.rogalsky@googlemail.com> - 2011-09-16 09:55 +0000
| From | Peter Sisak <p-kun80@hotmail.com> |
|---|---|
| Date | 2011-09-15 08:53 +0000 |
| Subject | "Traveling salesman on a hemisphere" problem |
| Message-ID | <j4see5$sp4$1@smc.vnet.net> |
I need to find an optimised roundtrip path for a list of objects given with polar coordinates on a unit sphere (actually, they are sky objects). I have a list of objects, such as:
{M51,{21,44.7}}
{NGC2721,{4,-17}}
{a funny comet,{57.3,7}}
{absolutely must see,{23,-176.3}}
In which list, the name of the celestial object is the string (may contain spaces, hashes, slashes, hyphens &c.), then its position is given with the pair {elevation(inclination/altitude),azimuth}. Elevation, since we are talking about sky objects, will be between 0 and 90 inclusive (0 being right on the horizon, 90 right above the observer's head; items with a negative elevation are under the horizon and they are not considered in the current problem); azimuth ranges from 180 to 180 inclusive, and gives the compass direction of the same object (0 being North, +-180 being South, +90 East, 90 West).
If one simply maps the coordinates onto an orthogonal coordinate system, it helps a little, but is not exact, for the reason that the linear distance between two objects is not constant (it grows as you proceed towards the horizon/decrease elevation) with this mapping. There doesn't exist such a mapping that would convert the angular distances into linear distances without distortion while being able to map a full hemisphere.
What I want to get as an output is the ordered list of the entire input object list, preferably with all data unchanged apart from their order. If a total length of roundrip path (in total angular length) would be calculated, that would be even more helpful. Text/spreadsheet file import for the list of objects, even better.
Thank you for your assistance in advance
Peter Sisak
[toc] | [next] | [standalone]
| From | Olaf <olaf.rogalsky@googlemail.com> |
|---|---|
| Date | 2011-09-16 09:55 +0000 |
| Message-ID | <j4v6f2$c97$1@smc.vnet.net> |
| In reply to | #4982 |
Hi Peter,
with the arclen from http://en.wikipedia.org/wiki/Great-circle_distance,
the following code will give you the shortest route.
stars = {
{"M51", {21, 44.7}},
{"NGC2721", {4, -17}},
{"a funny comet", {57.3, 7}},
{"absolutely must see", {23, -176.3}}};
arclen[{_, {F1_, L1_}}, {_, {F2_, L2_}}] :=
Module[{f1 = F1 Degree, l1 = L1 Degree, f2 = F2 Degree, l2 = L2
Degree, dl = (L1 - L2) Degree},
ArcTan[Sin[f1] Sin[f2] + Cos[f1] Cos[f2] Cos[dl],
Sqrt[(Cos[f2] Sin[dl])^2 + (Cos[f1] Sin[f2] - Sin[f1]
Cos[f2] Cos[dl])^2]]]
tour = FindShortestTour[stars, DistanceFunction -> arclen]
sortedStars = starlist[[tour[[2]]]]
And here some eye-candy:
p2c[{_, {f_, l_}}] := {Cos[f Degree] Cos[l Degree],
Sin[f Degree] Cos[l Degree], Sin[l Degree]}
greatCircleArc[{q_, p_}] :=
Module[{u = p2c[q], v = p2c[p], a}, a = VectorAngle[u, v];
Table[Evaluate[RotationTransform[t, {u, v}][u]], {t, 0, a,
a/Ceiling[10 a]}]]
Graphics3D[
{Sphere[{0, 0, 0}, 0.97],
{Black, Thick, Arrow[{{0, 0, -1.3}, {0, 0, 1.3}}]},
{Red, PointSize[Medium], Point[Map[p2c, sortedStars]]},
{Blue, Thick,
Map[Line, Map[greatCircleArc, Partition[sortedStars, 2, 1]]]}
}, SphericalRegion -> True]
Regards, Olaf
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web