I had a quick look at the intersection code from the sympy circle class:elif isinstance(o, Ellipse): a, b, r = o.hradius, o.vradius, self.radius x = a*sqrt(simplify((r**2 - b**2)/(a**2 - b**2))) y = b*sqrt(simplify((a**2 - r**2)/(a**2 - b**2))) return list(set([Point(x,y), Point(x,-y), Point(-x,y), Point(-x,-y)]))Looking at this code it seems that there whose an assumption of concentric figures. Regards,Matteo From: [email protected] To: [email protected] Cc: Date: Wed, 8 Sep 2010 09:32:52 -0600 Subject: Re: [sympy] Wrong circle ellipse intersection
I don't know if this is the source of the problem or not, but I would recommend against using Rational(str(786959127181/10000000000)). What this is doing is first converting 786959127181/10000000000 into a float, then trying to convert it back again. This feature is useful if you only have the floating point representation of a number, but you have the full Rational form already. Thus, you should just use Rational(786959127181, 10000000000).> > Worse, if you don't happen to have "from __future__ import division", it will truncate the number first (integer division). > > (By the way, if any behavior in sympy seems to go against what is documented, it is probably a bug)> > Aaron Meurer> > > On Sep 8, 2010, at 5:17 AM, [email protected] wrote: Hi all,I got the following code: print "ell circle 1"p1= Point(Rational(str(-351)), Rational(str(-2)))eci1=intersection(Ellipse(p1, Rational(str(50)), Rational(str(100))), Circle(p1, Rational(str(786959127181/10000000000))))for p in eci1: print "Point ",pprint "ell circle 2"p2=Point(Rational(str(0)), Rational(str(0)))eci2=intersection(Ellipse(p2, Rational(str(50)), Rational(str(100))),Circle(p2, Rational(str(786959127181/10000000000))))for p in eci2: print "Point ",p> > If you run this code you will notice that the intersection points are similar in both the intersection:> > ell circle 1> Point Point(-2*2937**(1/2)/3, 32*42**(1/2)/3)> Point Point(2*2937**(1/2)/3, -32*42**(1/2)/3)> Point Point(-2*2937**(1/2)/3, -32*42**(1/2)/3)> Point Point(2*2937**(1/2)/3, 32*42**(1/2)/3)> ell circle 2> Point Point(-2*2937**(1/2)/3, 32*42**(1/2)/3)> Point Point(2*2937**(1/2)/3, -32*42**(1/2)/3)> Point Point(-2*2937**(1/2)/3, -32*42**(1/2)/3)> Point Point(2*2937**(1/2)/3, 32*42**(1/2)/3)> > it seems that the intersection is made like the two entity are centred in the 0,0 coordinate.> It's a bug or it have to work in this way ?> > Regards,> Matteo> > > > > > > > > > > -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en. -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en. -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
