views:

1218

answers:

5

It does not need to be very accurate. Does anyone know a good way to do this?

any help is much appreciated.

+2  A: 

I'd say find the closest point on the line to the center of the circle, then determine whether that point is within the circle (i.e. the distance in question is less than or equal to the circle's radius).

chaos
sounds good, any ideas about the projection/conversion from lat,lon to 2d coordinates?
http://board.flashkit.com/board/archive/index.php/t-666832.html seems useful.
chaos
Chaos has it right. Unless I'm missing something, all the conversions wash out except the radius, which needs to be converted so that you're comparing apples to apples. See http://mathworld.wolfram.com/CircularSegment.html for how to do that part.
dwc
No need to convert lat-lon to 2D coordinates; in fact that will probably just cause problems. Find the closest point in 3D space. The "line" becomes a great circle in 3D space.
Die in Sente
A: 

Assuming line is formed by points (x1, y1) and (x2, y2), and circle has radius r with origin (0,0):

Calculate: Incidence = r^2 * [(x2 - x1)^2 + (y2 - y1)^2] - (x1 * y2 - x2 * y1)^2

Then, from the value of Incidence, we can determine the following: Incidence < 0: No intersection Incidence = 0: Tangent (intersection at 1 point on circle) Incidence > 0: Intersection

It's likely your circle is not at the origin (0,0), so to fix this, just add the origin coordinates from your line coordinates in the equation above. So, if the circle is at (x3, y3), x1 in the above equation would become x1 + x3. Likewise, y1 would be y1 + y3, and the same goes for x2 and y2.

For more info check out this link

MahlerFive
That's fine for points on a plane, but the earth is not flat.
Die in Sente
+1  A: 

Outline for solving the problem: assume the Earth is a sphere of radius one centered at the origin. Convert all three lat, lon points to 3D coordinates. The two points of the line plus the origin define a plane; intersect that plane with the sphere of radius d centered on the other point. If there is no plane-sphere intersection, then the answer is the line does not intersect the region. If there is a plane-sphere intersection, then the problem is simplified to intersecting the circular region defined by the plane-sphere intersection with the shortest circular arc on the plane going between the end points of the line and centered at the origin. This is a straightforward 2D problem if you convert to the coordinate system of the plane.

Sol
If there is a plane-sphere intersection, then the answer is "yes".
quant_dev
Not true -- the plane might intersect while the circular arc on the plane we are actually interested in does not.
Sol
+1  A: 

This question is too vague to be answered precisely. What do you mean by

a line form by 2 geo points (lat, lon)

This can be either a great circle going through them (also called orthodrome) or it a can be a linear function of spherical coordinates (loxodrome).

BTW, I assume your circle is a circle on the surface of the sphere, right?

quant_dev
+4  A: 
Gareth Rees