Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.c Subject: Re: Efficient algorithm needed Message-ID: <11959:Mar2000:15:3791@kramden.acf.nyu.edu> Date: 20 Mar 91 00:15:37 GMT References: <2538@odin.cs.hw.ac.uk> <4987@goanna.cs.rmit.oz.au> <27497@uflorida.cis.ufl.EDU> Organization: IR Lines: 20 X-Right-Newsgroups: comp.programming In article <27497@uflorida.cis.ufl.EDU> jdb@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