LineSegment/Ellipse Intersection: I'm stuck

Started by
2 comments, last by GPxz 16 years, 6 months ago
I have been working on code to calculate the intersection of a line Segment and an ellipse, and I cannot seem to get it to work. I cannot even get a co-planar case to work, so I must be doing something fundamentally wrong. After admitting defeat myself, I decided to see if I could find some example code on the 'net. I found a lot of code, but none that I could comprehend. I am not familiar with C++ and the libraries that do line/ellipse intersections are too convoluted for a non-C person like myself to follow. (Yes, I need to learn C++. Ive started learning, but computational geometry libraries are probably not the place to start :) ) Could some kind soul out there give me a psuedocode example, or a basic strategy, or a self contained C++ snippet that calculates the intersection point(s) of a line segment and a ellipse? If it matters, I'm programming in VB.net and drawing with Opengl. These intersection calculations are not in the main loop, so computational efficiency isn't critical. Any help anyone can give me would be greatly appreciated. Thanks!
Advertisement
Reduce it to simpler problems:

1) segment and circle
The ellipse can be obtained from a circle by stretching it along the direction of either axis; the same trivially invertible stretching transforms line segments to line segments.

2) line and circle
With a parametric representation of the line containing the segment's extremes, checking whether each intersection of the line or the single tangency point belongs to the segment is easy.

3) Some particularly easy choice of any two of line (e.g. x=1), circle center (e.g. (0,0)) or circle radius (e.g. 1)
Another simple translation, rotation and scaling.

Omae Wa Mou Shindeiru

1) segment and circle
The ellipse can be obtained from a circle by stretching it along the direction of either axis; the same trivially invertible stretching transforms line segments to line segments.


I never thought of that! I will give it a try. Thanks!

Quote:Original post by Flatus
1) segment and circle
The ellipse can be obtained from a circle by stretching it along the direction of either axis; the same trivially invertible stretching transforms line segments to line segments.


I never thought of that! I will give it a try. Thanks!


Good idea
My MSN: gerunbaum@hotmail.com

This topic is closed to new replies.

Advertisement