Walt Mankowski on Wed, 8 May 2002 02:30:15 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] math help for this graphing program I'm writing to graph the keyring ?


On Tue, May 07, 2002 at 07:09:26PM -0400, Darxus@chaosreigns.com wrote:
> http://www.chaosreigns.com/code/springgraph/diagram.jpg
> 
> The axes of the ellipse are paralel to the coordinate axes.
> 
> I know the x,y coordinates of the center of the ellipse.  
> 
> I know the height and width of the ellipse.
> 
> I know angle A (it can be anything)
> 
> I am trying to find either the length of line B (radius of the ellipse
> at the given angle), or the x,y coordinates of the intersection of line
> B with the edge of the ellipse (from this I can easily calculate the length).
> 
> Ian suggested finding the coordinates of the two foci, using the line
> between them as a base of a triangle, and the intersection of line B
> with the edge of the ellipse as the opposite point of the triangle.

Since you have the angle and are trying to find the radius, it's a lot
easier if you use the polar coordinates version of the equation of an
ellipse.  You can find it derived at http://mathworld.wolfram.com/Ellipse.html
(and undoubtedly lots of other places).

Simplifying a bit what's written there, the equation you want is

r = sqrt( (b^2 * a^2) / ( (b^2 * cos(theta)) + (a^2 * sin(theta)) ) )

where...

b     is the height of the ellipse above its center (x,y)
a     is the width of the ellipse from its center (x,y)
theta is the angle you call A in your diagram
r     is the distance from the center of the ellipse to the edge

Note that a and b are measured from the *center*, and not from
top-to-bottom or left-to-right.

Have fun!

Walt

Attachment: pgpGPiio3Vtg9.pgp
Description: PGP signature