| Calculating Intersect Points |
|
| 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:
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):
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
http://www.xrumer7.com
RSS feed for comments to this post.