Hello,

This is more of a note of my findings and also just implicitly
verifying whether I am doing the right thing.

Problem: I want to find whether a point lies on a circle.

I was hoping that like Linear entity objects, the circle/ellipse would
have a contains() method as well. But, contains() in the context of a
circle or ellipse certainly means something else and I see that there
is an encloses() method for that purpose.

So, to do what I want to, this is my plan of action:

- Find the equation of the circle
- Substitute the point's co-ordinates in the above equation and see if
it equates to 0

>>> from sympy import Point, Circle
>>> p = Point(0,0)
>>> c = Circle(p,1)
>>> c
Circle(Point(0, 0), 1)

>>> eq_c=c.equation()
>>> eq_c.subs({x:0,y:1})
x**2 + y**2 - 1

That is not what I expect. Trying out a few other things (restarting
the shell, etc), I finally hit the idea that may be the x and y in the
equation are different objects from the ones I am specifying to
subs(). So:

>>> x=Symbol('x')
>>> y=Symbol('y')
>>> eq_c=c.equation(x=x,y=y)
>>> eq_c.subs({x:0,y:1})
0

And I have what I wanted to find

(The same reasoning also applies if I want to use the solve() method
and also to equations of other objects).

Query 1: Is there any reason why we don't have a method for finding
whether a point lies on a circle/ellipse?


Thanks for reading.

Best,
Amit.
--
http://echorand.me

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to