def is_concyclic(*points): """Is a sequence of points concyclic? Test whether or not a sequence of points are concyclic (i.e., they lie on a circle). Parameters ---------- points : sequence of Points Returns ------- is_concyclic : boolean True if points are concyclic, False otherwise. Notes ----- No points are not considered to be concyclic. One or two points are definitely concyclic and three points are conyclic iff they are not collinear. For more than three points, create a circle from the first three points. If the circle cannot be created (i.e., they are collinear) then all of the points cannot be concyclic. If the circle is created successfully then simply check the remaining points for containment in the circle. Examples -------- >>> from sympy.geometry import Point >>> p1, p2 = Point(-1, 0), Point(1, 0) >>> p3, p4 = Point(0, 1), Point(-1, 2) >>> Point.is_concyclic(p1, p2, p3) True >>> Point.is_concyclic(p1, p2, p3, p4) False """ if len(points) == 0: return False if len(points) <= 2: return True points = [Point(p) for p in points] if len(points) == 3: return (not Point.is_collinear(*points)) try: from ellipse import Circle c = Circle(points[0], points[1], points[2]) for point in points[3:]: if point not in c: return False return True except GeometryError, e: # Circle could not be created, because of collinearity of the # three points passed in, hence they are not concyclic. return False
def is_concyclic(*points): """ Test whether or not a set of points are concyclic (i.e., on the same circle). Returns True if they are concyclic, or False otherwise. Example: ======== >>> from sympy.geometry import Point >>> p1,p2 = Point(-1, 0), Point(1, 0) >>> p3,p4 = Point(0, 1), Point(-1, 2) >>> Point.is_concyclic(p1, p2, p3) True >>> Point.is_concyclic(p1, p2, p3, p4) False Description of method used: =========================== No points are not considered to be concyclic. One or two points are definitely concyclic and three points are conyclic iff they are not collinear. For more than three points, we pick the first three points and attempt to create a circle. If the circle cannot be created (i.e., they are collinear) then all of the points cannot be concyclic. If the circle is created successfully then simply check all of the other points for containment in the circle. """ points = GeometryEntity.extract_entities(points) if len(points) == 0: return False if len(points) <= 2: return True if len(points) == 3: return (not Point.is_collinear(*points)) try: from ellipse import Circle c = Circle(points[0], points[1], points[2]) for point in points[3:]: if point not in c: return False return True except GeometryError, e: # Circle could not be created, because of collinearity of the # three points passed in, hence they are not concyclic. return False
def incircle(self): """The incircle of the RegularPolygon. Returns ------- incircle : Circle See Also -------- Circle Examples -------- >>> from sympy.geometry import RegularPolygon, Point >>> rp = RegularPolygon(Point(0, 0), 4, 8) >>> rp.incircle Circle(Point(0, 0), 4*cos(pi/8)) """ return Circle(self.center, self.apothem)
def circumcircle(self): """The circumcircle of the RegularPolygon. Returns ------- circumcircle : Circle See Also -------- Circle Examples -------- >>> from sympy.geometry import RegularPolygon, Point >>> rp = RegularPolygon(Point(0, 0), 4, 8) >>> rp.circumcircle Circle(Point(0, 0), 4) """ return Circle(self.center, self.radius)
def circumcircle(self): """The circle which passes through the three vertices of the triangle. Returns ------- circumcircle : Circle See Also -------- Circle Examples -------- >>> from sympy.geometry import Point, Triangle >>> p1, p2, p3 = Point(0, 0), Point(1, 0), Point(0, 1) >>> t = Triangle(p1, p2, p3) >>> t.circumcircle Circle(Point(1/2, 1/2), sqrt(2)/2) """ return Circle(self.circumcenter, self.circumradius)
def incircle(self): """The incircle of the triangle. The incircle is the circle which lies inside the triangle and touches all three sides. Returns ------- incircle : Circle See Also -------- Circle Examples -------- >>> from sympy.geometry import Point, Triangle >>> p1, p2, p3 = Point(0, 0), Point(2, 0), Point(0, 2) >>> t = Triangle(p1, p2, p3) >>> t.incircle Circle(Point(-sqrt(2) + 2, -sqrt(2) + 2), -sqrt(2) + 2) """ return Circle(self.incenter, self.inradius)
def incircle(self): """The incircle of the triangle.""" return Circle(self.incenter, self.inradius)
def circumcircle(self): """The circumcircle of the triangle.""" return Circle(self.circumcenter, self.circumradius)
def incircle(self): """Returns a Circle instance describing the inscribed circle.""" return Circle(self.center, self.apothem)
def circumcircle(self): """Returns a Circle instance describing the circumcircle.""" return Circle(self.center, self.radius)