实体#
- class sympy.geometry.entity.GeometryEntity(*args, **kwargs)[源代码]#
所有几何图元的基类。
This class does not represent any particular geometric entity, it only provides the implementation of some methods common to all subclasses.
- property ambient_dimension#
物体所在空间的尺寸是多少?
- property bounds#
xmax,在矩形中表示xmax,表示图形中的xmax。
- encloses(o)[源代码]#
如果o在自我的边界之内(不是在或之外),返回True。
对象将被分解为点,单个实体只需为其类定义一个encloses_point方法。
实例
>>> 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)[源代码]#
返回self与o的所有交集的列表。
笔记
实现此方法不需要实体。
如果两种不同类型的实体可以相交,那么在排序的类中具有较高索引的项应该实现与索引较低的任何项的交集。
- is_similar(other)[源代码]#
这个几何实体和另一个几何实体相似吗?
如果一个实体的统一缩放(放大或缩小)将允许一个实体获得另一个实体,则两个实体是相似的。
笔记
此方法不打算直接使用,而是通过 \(are_similar\) 在中找到函数实用程序.py. 实现此方法不需要实体。如果两种不同类型的实体可以相似,只需要其中一种能够确定。
参见
- parameter_value(other, t)[源代码]#
返回相应的参数。在该参数值处计算实体的任意点将返回给定点。
实例
>>> 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)[源代码]#
在一条直线上反射一个物体。
- 参数:
行:行
实例
>>> 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)[源代码]#
旋转
angle
点的逆时针弧度pt
.默认pt是原点,点(0,0)
实例
>>> 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)[源代码]#
用x,y坐标乘以x和y来缩放对象。
如果给定pt,则相对于该点进行缩放;对象按-pt移动、缩放并按pt移动。
实例
>>> 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)[源代码]#
通过添加x,y坐标值x和y来移动对象。
实例
>>> 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))