Entities
- class sympy.geometry.entity.GeometryEntity(*args, **kwargs)[source]
The base class for all geometrical entities.
This class doesn’t represent any particular geometric entity, it only provides the implementation of some methods common to all subclasses.
- property ambient_dimension
What is the dimension of the space that the object is contained in?
- property bounds
Return a tuple (xmin, ymin, xmax, ymax) representing the bounding rectangle for the geometric figure.
- encloses(o)[source]
Return True if o is inside (not on or outside) the boundaries of self.
The object will be decomposed into Points and individual Entities need only define an encloses_point method for their class.
Examples
>>> from sympy import RegularPolygon, Point, Polygon >>> t = Polygon(*RegularPolygon(Point(0, 0), 1, 3).vertices) >>> t2 = Polygon(*RegularPolygon(Point(0, 0), 2, 3).vertices) >>> t2.encloses(t) True >>> t.encloses(t2) False
- intersection(o)[source]
Returns a list of all of the intersections of self with o.
Notes
An entity is not required to implement this method.
If two different types of entities can intersect, the item with higher index in ordering_of_classes should implement intersections with anything having a lower index.
See also
- is_similar(other)[source]
Is this geometrical entity similar to another geometrical entity?
Two entities are similar if a uniform scaling (enlarging or shrinking) of one of the entities will allow one to obtain the other.
Notes
This method is not intended to be used directly but rather through the \(are_similar\) function found in util.py. An entity is not required to implement this method. If two different types of entities can be similar, it is only required that one of them be able to determine this.
See also
- parameter_value(other, t)[source]
Return the parameter corresponding to the given point. Evaluating an arbitrary point of the entity at this parameter value will return the given point.
Examples
>>> from sympy import Line, Point >>> from sympy.abc import t >>> a = Point(0, 0) >>> b = Point(2, 2) >>> Line(a, b).parameter_value((1, 1), t) {t: 1/2} >>> Line(a, b).arbitrary_point(t).subs(_) Point2D(1, 1)
- reflect(line)[source]
Reflects an object across a line.
- Parameters
line: Line
Examples
>>> from sympy import pi, sqrt, Line, RegularPolygon >>> l = Line((0, pi), slope=sqrt(2)) >>> pent = RegularPolygon((1, 2), 1, 5) >>> rpent = pent.reflect(l) >>> rpent RegularPolygon(Point2D(-2*sqrt(2)*pi/3 - 1/3 + 4*sqrt(2)/3, 2/3 + 2*sqrt(2)/3 + 2*pi/3), -1, 5, -atan(2*sqrt(2)) + 3*pi/5)
>>> from sympy import pi, Line, Circle, Point >>> l = Line((0, pi), slope=1) >>> circ = Circle(Point(0, 0), 5) >>> rcirc = circ.reflect(l) >>> rcirc Circle(Point2D(-pi, pi), -5)
- rotate(angle, pt=None)[source]
Rotate
angle
radians counterclockwise about Pointpt
.The default pt is the origin, Point(0, 0)
Examples
>>> from sympy import Point, RegularPolygon, Polygon, pi >>> t = Polygon(*RegularPolygon(Point(0, 0), 1, 3).vertices) >>> t # vertex on x axis Triangle(Point2D(1, 0), Point2D(-1/2, sqrt(3)/2), Point2D(-1/2, -sqrt(3)/2)) >>> t.rotate(pi/2) # vertex on y axis now Triangle(Point2D(0, 1), Point2D(-sqrt(3)/2, -1/2), Point2D(sqrt(3)/2, -1/2))
- scale(x=1, y=1, pt=None)[source]
Scale the object by multiplying the x,y-coordinates by x and y.
If pt is given, the scaling is done relative to that point; the object is shifted by -pt, scaled, and shifted by pt.
Examples
>>> from sympy import RegularPolygon, Point, Polygon >>> t = Polygon(*RegularPolygon(Point(0, 0), 1, 3).vertices) >>> t Triangle(Point2D(1, 0), Point2D(-1/2, sqrt(3)/2), Point2D(-1/2, -sqrt(3)/2)) >>> t.scale(2) Triangle(Point2D(2, 0), Point2D(-1, sqrt(3)/2), Point2D(-1, -sqrt(3)/2)) >>> t.scale(2, 2) Triangle(Point2D(2, 0), Point2D(-1, sqrt(3)), Point2D(-1, -sqrt(3)))
- translate(x=0, y=0)[source]
Shift the object by adding to the x,y-coordinates the values x and y.
Examples
>>> from sympy import RegularPolygon, Point, Polygon >>> t = Polygon(*RegularPolygon(Point(0, 0), 1, 3).vertices) >>> t Triangle(Point2D(1, 0), Point2D(-1/2, sqrt(3)/2), Point2D(-1/2, -sqrt(3)/2)) >>> t.translate(2) Triangle(Point2D(3, 0), Point2D(3/2, sqrt(3)/2), Point2D(3/2, -sqrt(3)/2)) >>> t.translate(2, 2) Triangle(Point2D(3, 2), Point2D(3/2, sqrt(3)/2 + 2), Point2D(3/2, 2 - sqrt(3)/2))