Efficient algorithm needed

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Wed Mar 20 10:15:37 AEST 1991


In article <27497 at uflorida.cis.ufl.EDU> jdb at reef.cis.ufl.edu (Brian K. W. Hook) writes:
> Given an ellipse and a point, determine where a line from the center of the
> ellipse to the point will intersect the ellipse.
> You are give:
> The center of the ellipse
> The width of ellipse
> The height of the ellipse
> The X and Y coordinate of the point

What is the ellipse's orientation?

If it is not rotated, then a point (x,y) is on the edge of the ellipse
only if ((x - c)/w)^2 + ((y - d)/h)^2 = 1, where (c,d) is the center and
(h,w) are half of height and width. So to scale a point (x,y) to the
edge you should subtract (c,d), then divide by sqrt((x/w)^2 + (y/h)^2),
then add (c,d) back in.

Now what does this have to do with the C language?

---Dan



More information about the Comp.lang.c mailing list