Jason on Wed, 8 May 2002 02:50:12 +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 ?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 07 May 2002 20H:19, you wrote:
> 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)) ) )
>
Simplifying a bit further...
Would a rectangle work in this situation? Just a thought...

I believe that you were using perl, right? I'm not a serious Perl user 
(hmm... are any of them very serious?), but you might also want to check out 
the code in the Image::Base.pm module. I believe that it has an ellipse 
function. Also, a quick check on CPAN lists a Math::Geometry module which 
probably has some helpful stuff.

Oh, and all of the diagrams look quite snazzy...

HTH,
- -Jason
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAjzYc98ACgkQ3CryLfCgqRmgZQCggWY9vodZtWRxXAGJW9cNv7pu
fhIAn12jRja7sgVAyY1Iwp4GkMsPc3+1
=UNMi
-----END PGP SIGNATURE-----

______________________________________________________________________
Philadelphia Linux Users Group       -      http://www.phillylinux.org
Announcements-http://lists.phillylinux.org/mail/listinfo/plug-announce
General Discussion  -  http://lists.phillylinux.org/mail/listinfo/plug