# Correct usage of GeoPosition

My goal is to trace a ray down to the ground.

I have done:

{re, rp} = GeodesyData["ITRF00", #] & /@ {"SemimajorAxis", "SemiminorAxis"}
sat = {0, 2 re, 0};
point = Normalize[{.2, -1, .28}];
sol = FindRoot[GeoPosition[GeoPositionXYZ[sat + f point, "ITRF00"]][[1, 3]],{f,100}];


The idea is I'm starting at point sat with a ray in the direction of point. If this ray intersects with the earth there should be a point where GeoPosition[] will give a zero height. So far the results I have gotten seem right when I plot them and for simple cases but I get the following error messages:

GeoPositionXYZ::invcoord: {0.18911736861805847*f, 12756274 - 0.9455868430902923*f, 0.2647643160652819*f} is not a valid coordinate specification. >>
GeoPosition::invcoord: GeoPositionXYZ[{0.18911736861805847*f, 12756274 - 0.9455868430902923*f, 0.2647643160652819*f}, "ITRF00"] is not a valid coordinate specification. >>
Part::partw: Part 3 of GeoPositionXYZ[{0.189117 f,12756274-0.945587 f,0.264764 f},ITRF00] does not exist. >>
GeoPositionXYZ::invcoord: {#1, #2, #3} is not a valid coordinate specification. >>


Is there a better way to use GeoPosition[] with FindRoot[]?

-

There are two problems involved here. First, GeoPositionXYZ expects numeric arguments, which can be solved by defining an auxiliary function that only takes numeric arguments:

ClearAll[h];
h[f_?NumericQ] := GeoPosition[GeoPositionXYZ[sat + f point, "ITRF00"]][[1, 3]]


The second is to use good starting values. Yours is much too low for the value range involved. Providing a second step as an indication of the initially required coarseness of the root search approach helps as well:

sol = FindRoot[h[f], {f, 1000000, 2000000}];

GeoPosition[GeoPositionXYZ[sat + f point /. sol, "ITRF00"]][[1, 3]]


0.

-
Thank you this works well. Yes I know my starting values were poor. There are some simple calculations I can do to get good guesses. – c186282 Jul 7 '13 at 23:04