News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Computing ellipse edge intersection point

Started by tomkane, July 09, 2006, 05:54:10 PM

Previous topic - Next topic

tomkane

I'm not sure exactly what area of math I'm asking about -- but I have researched in the Wiki encyclopedia and found some formulas for computing the shape of an ellipse.

What I want to do is to be able to detect where a line crosses an ellipse's edge. In other words, I want to be able to draw a line between two ellipses, with the line attaching at user selectable points along the edge of the ellipse. I believe that this is being done by graphics software, so it must be doable.  :dazzled:

It doesn't have to be calculated with infinite precision as the connection point could be estimated +/- 2 pixels along the edge. I imagine I could build up an array of points along the edge of the ellipse and then determine if the user is moving within the range of any rectangle that bounds a point by those +/- 2 pixels. Then make the attachment at that located point along the ellipse's arc.

Surely this is a fairly simple algorithm but I'm too simple to be able to figure out by myself. If anyone can interpret what I'm looking for I'll be grateful. :cheekygreen:

Thanks for any suggestions.

Tom Kane

dsouza123

google intersection line ellipse
from the links there is code (not assembly) and explanations.

The math would be analytic geometry.

Ratch

tomkane,

QuoteWhat I want to do is to be able to detect where a line crosses an ellipse's edge.

     Do you mean the intersection of the line with the ellipse?

QuoteI want to be able to draw a line between two ellipses, with the line attaching at user selectable points along the edge of the ellipse

     User selectable points at just one or both ellipses?

QuoteI believe that this is being done by graphics software, so it must be doable

     Only if you can specify what you want.  OK let's see now.  You know where one end of the line is because it is user selected.  Now, where does the line go from there.  Does it intersect the second ellipse at any of an infinite number of points?  What is the criteria for defining the line?  You need to specify what you want more clearly.  Ratch


tomkane

Thanks for the feedback.  :clap:

I finally figured out what it is that I want to do. I want to be able to calculate plot points along the edge of an ellipse. The easiest way to visualize what I want is to think of the old days with dot matrix printers and how you would use a Basic program to plot/print out an ellipse on paper using asterisks for the plot points.

All I want to do is create an array of those plot points. Then in my application (a bubble diagram using ellipses to surround text), I will allow the user to click on the edge of a pre-drawn ellipse (I'll use the simple Windows Ellipse function for that part), I'll search the plot points array for the point that is closest to the point clicked. As I mentioned, I'll use some sort of rectangle for approximate range evaluation. Once the search is complete, I'll have my intersection point. I can then draw a line between two ellipses' respective intersection points.

I was self-taught in trigonometry and calculus, and that was a long time ago. So when I looked at web sites with formulas for ellipses, I was blown away by all the greek characters, cos, tan, and eigen values. Give me a simple formula like (x^2 / a^2) + (y^2 / b^2) = 1 any day of the week.

I realize now that this wasn't the topic area for this question -- I was merely hoping that there was a library out there with a function that would hand me back plot points. Now that I know how simple the formula  is, I would just as soon build my own.  :dance:

Thanks again.

Tom Kane

Ratch

tomkane,

QuoteAll I want to do is create an array of those plot points.

     First decide on how many points you want to use to represent the ellipse.  Next, calculate the points after determining what the reference (0,0) point will be.  You already appear to know the basic formula of an ellipse, whose major and minor axes are parallel to the x-axis and y-axis.  If you need more than one ellipse, calculate the next one, and put the points in memory after the first one to make an array.  Then go on from there.  Ratch