Calculating Intersect Points Print
User Rating: / 1
PoorBest 
Written by Xuro   
Wednesday, 31 March 2010 07:20

A visitor to my site (Hi Jay!) recently made use of my sample code for detecting the intersection between a point and a line segment, and was inquiring about how to calculate the precise point(s) of intersection between a circle and a line.  Naturally, I thought that would make a good topic for a new post.  :D

 

In general, the math to calculate intersection points involves using what you know about the objects in question (XY points, radii, etc) to derive equations representing the objects, and then solve the system of equations to identify the precise points where the objects intersect.  I'm familiar (albeit a bit rusty) with the math but have never done it in code so I felt it would be an interesting thing to play around with.  However, as sometimes happens, while researching to make sure there wasn't a better way or a built-in function or whatnot in C#, I came across an excellent article at blog.csharphelper.com about this precise question - it's in C#, has a downloadable sample and everything.  Beyond that, the site has a number of other interesting posts so rather than reinventing the wheel I wanted to share this resource with all of you.  

 

 

Here are some of his articles about calculating intersection points I'd like to highlight:

 

world_link Determine where a line intersects a circle in C#

world_link Determine where two circles intersect in C#

world_link Determine where the lines defined by two segments intersect in C#

 

If you'd like more "behind the scenes" info, here's a good article from a different site on some elements of circle math, including finding the line-circle intersection point(s):

 

world_link The Circle

 

Note that when finding where a circle and line intersect, if they intersect there can be two points or only one point (where the line is a tangent to the circle).  Hope you find the links helpful!

 

Last Updated on Wednesday, 31 March 2010 10:50
 

Comments  

 
#1 trosilialsirl 2011-02-11 00:59
Xrumer 7 SEO Put my site to the top in 3 days. Truly the greatest decision we ever made. http://www.youtube.com/watch?v=WnJTqtKcF08
http://www.xrumer7.com
Quote
 

Add comment

Security code
Refresh

Sunday, 20. May 2012

Design by: LernVid.com