Hướng dẫn python polygon class - lớp đa giác trăn
>>> %pylab inline Populating the interactive namespace from numpy and matplotlib Show File " >>> from pylayers.util.geomutil import * >>> from pylayers.util.plotutil import * >>> import matplotlib.pyplot as plt >>> import shapely.geometry as shg Geomutil là một mô -đun tập hợp các chức năng hình học khác nhau được sử dụng trong các mô -đun của trụ khác. is a module which gathers different geometrical functions used in other module of pylayers. Lớp này thực hiện biểu đồ tầm nhìn, của một đa giác. Lớp đa giác là một lớp con của lớp đa giác hình dạng. Nó cho phép khởi tạo một đa giác với các đối tượng khác nhau (list, np.array, sh.multipoint) >>> points = shg.MultiPoint([(0, 0), (1, 1), (2, 0), (1, 0),(0,-2)]) >>> poly1 = Polygon(points) >>> poly2 = Polygon(p=[[3,4,4,3],[1,1,2,2]]) >>> N = 7 >>> phi = np.linspace(0,2*np.pi,N) >>> x = 3*np.cos(phi)+5 >>> y = 3*np.sin(phi)+5 >>> nppoints = np.vstack((x,y)) >>> poly3 = Polygon(nppoints) âm mưu đa giác>>> fig = plt.figure() >>> ax = fig.gca() >>> plt.axis('off') >>> plt.axis('equal') >>> fig,ax=poly1.plot(color='green',fig=fig,ax=ax) >>> fig,ax=poly2.plot(color='red',fig=fig,ax=ax) >>> fig,ax=poly3.plot(color='#000000',fig=fig,ax=ax) buildgv ()¶Mối quan hệ hiển thị dertermine trong một đa giác. Trả về một biểu đồ Chức năng này được sử dụng để xác định mối quan hệ hiển thị trong môi trường trong nhà. >>> fig = plt.figure(figsize=(8,8)) >>> points = shg.MultiPoint([(0, 0), (0, 1), (2.5,1), (2.5, 2), \ ... (2.8,2), (2.8, 1.1), (3.2, 1.1), \ ... (3.2, 0.7), (0.4, 0.7), (0.4, 0)]) >>> polyg = Polygon(points) >>> Gv = polyg.buildGv(show=True) >>> plt.axis('off') (-0.5, 4.0, -0.5, 2.5) TypeErrorTraceback (most recent call last) Các lớp GeomviewGeomvect class¶Lớp này được sử dụng để tương tác với Trình xem 3D Geomview. geomomase¶Hiển thị một cơ sở >>> v1 = np.array([1,0,0]) >>> v2 = np.array([0,1,0]) >>> v3 = np.array([0,0,1]) >>> M = np.vstack((v1,v2,v3)) >>> gv = GeomVect('test') >>> gv.geomBase(M) >>> #gv.show3() điểm trongHiển thị một tập hợp các điểm >>> gv1 = GeomVect('test1') >>> gv1.points(np.random.rand(3,10)) >>> #gv1.show3() Phương thức Ndarray chuyển đổi một đối tượng đa giác thành một ndarray >>> geo = Geomoff('test2') >>> pt = poly3.ndarray().T >>> pt1 = np.hstack((pt,np.zeros((7,1)))) Lớp này được sử dụng trong mô -đun vrml2geom File "0 File "1 File "2 File "3 File "4 âm mưu hộpFile "5 Các chức năng tiện ích¶góc cạnhgóc cạnh chuyển đổi một vectơ 3D thành góc hình cầu 2, được biểu thị bằng radian File "6 File "7 lớp lơnFile "8 DPTSEG (P, PT, PH) ¶Hàm này tính toán khoảng cách giữa một tập hợp các điểm và một phân đoạn File "9 >>> from pylayers.util.geomutil import * >>> from pylayers.util.plotutil import * >>> import matplotlib.pyplot as plt >>> import shapely.geometry as shg0 >>> from pylayers.util.geomutil import * >>> from pylayers.util.plotutil import * >>> import matplotlib.pyplot as plt >>> import shapely.geometry as shg1 sự biểu lộ>>> from pylayers.util.geomutil import * >>> from pylayers.util.plotutil import * >>> import matplotlib.pyplot as plt >>> import shapely.geometry as shg2 Ptonseg (PTA, PHE, PT) ¶được sử dụng trong select.py >>> from pylayers.util.geomutil import * >>> from pylayers.util.plotutil import * >>> import matplotlib.pyplot as plt >>> import shapely.geometry as shg3 >>> from pylayers.util.geomutil import * >>> from pylayers.util.plotutil import * >>> import matplotlib.pyplot as plt >>> import shapely.geometry as shg4 ptconvex¶>>> from pylayers.util.geomutil import * >>> from pylayers.util.plotutil import * >>> import matplotlib.pyplot as plt >>> import shapely.geometry as shg5 >>> from pylayers.util.geomutil import * >>> from pylayers.util.plotutil import * >>> import matplotlib.pyplot as plt >>> import shapely.geometry as shg6 giao nhau¶Giao nhau (a, b, c, d) wether hay không các phân đoạn N (AB) giao với các phân đoạn N (CD). Giao lộ chỉ được kiểm tra cho phân đoạn của cùng một chỉ số trong ndarray. >>> from pylayers.util.geomutil import * >>> from pylayers.util.plotutil import * >>> import matplotlib.pyplot as plt >>> import shapely.geometry as shg7 >>> from pylayers.util.geomutil import * >>> from pylayers.util.plotutil import * >>> import matplotlib.pyplot as plt >>> import shapely.geometry as shg8 >>> from pylayers.util.geomutil import * >>> from pylayers.util.plotutil import * >>> import matplotlib.pyplot as plt >>> import shapely.geometry as shg9 >>> points = shg.MultiPoint([(0, 0), (1, 1), (2, 0), (1, 0),(0,-2)]) >>> poly1 = Polygon(points) >>> poly2 = Polygon(p=[[3,4,4,3],[1,1,2,2]]) >>> N = 7 >>> phi = np.linspace(0,2*np.pi,N) >>> x = 3*np.cos(phi)+5 >>> y = 3*np.sin(phi)+5 >>> nppoints = np.vstack((x,y)) >>> poly3 = Polygon(nppoints)0 >>> from pylayers.util.geomutil import * >>> from pylayers.util.plotutil import * >>> import matplotlib.pyplot as plt >>> import shapely.geometry as shg8 >>> points = shg.MultiPoint([(0, 0), (1, 1), (2, 0), (1, 0),(0,-2)]) >>> poly1 = Polygon(points) >>> poly2 = Polygon(p=[[3,4,4,3],[1,1,2,2]]) >>> N = 7 >>> phi = np.linspace(0,2*np.pi,N) >>> x = 3*np.cos(phi)+5 >>> y = 3*np.sin(phi)+5 >>> nppoints = np.vstack((x,y)) >>> poly3 = Polygon(nppoints)2 >>> points = shg.MultiPoint([(0, 0), (1, 1), (2, 0), (1, 0),(0,-2)]) >>> poly1 = Polygon(points) >>> poly2 = Polygon(p=[[3,4,4,3],[1,1,2,2]]) >>> N = 7 >>> phi = np.linspace(0,2*np.pi,N) >>> x = 3*np.cos(phi)+5 >>> y = 3*np.sin(phi)+5 >>> nppoints = np.vstack((x,y)) >>> poly3 = Polygon(nppoints)3 >>> points = shg.MultiPoint([(0, 0), (1, 1), (2, 0), (1, 0),(0,-2)]) >>> poly1 = Polygon(points) >>> poly2 = Polygon(p=[[3,4,4,3],[1,1,2,2]]) >>> N = 7 >>> phi = np.linspace(0,2*np.pi,N) >>> x = 3*np.cos(phi)+5 >>> y = 3*np.sin(phi)+5 >>> nppoints = np.vstack((x,y)) >>> poly3 = Polygon(nppoints)4 Các chức năng hữu ích>>> points = shg.MultiPoint([(0, 0), (1, 1), (2, 0), (1, 0),(0,-2)]) >>> poly1 = Polygon(points) >>> poly2 = Polygon(p=[[3,4,4,3],[1,1,2,2]]) >>> N = 7 >>> phi = np.linspace(0,2*np.pi,N) >>> x = 3*np.cos(phi)+5 >>> y = 3*np.sin(phi)+5 >>> nppoints = np.vstack((x,y)) >>> poly3 = Polygon(nppoints)5 >>> points = shg.MultiPoint([(0, 0), (1, 1), (2, 0), (1, 0),(0,-2)]) >>> poly1 = Polygon(points) >>> poly2 = Polygon(p=[[3,4,4,3],[1,1,2,2]]) >>> N = 7 >>> phi = np.linspace(0,2*np.pi,N) >>> x = 3*np.cos(phi)+5 >>> y = 3*np.sin(phi)+5 >>> nppoints = np.vstack((x,y)) >>> poly3 = Polygon(nppoints)6 >>> points = shg.MultiPoint([(0, 0), (1, 1), (2, 0), (1, 0),(0,-2)]) >>> poly1 = Polygon(points) >>> poly2 = Polygon(p=[[3,4,4,3],[1,1,2,2]]) >>> N = 7 >>> phi = np.linspace(0,2*np.pi,N) >>> x = 3*np.cos(phi)+5 >>> y = 3*np.sin(phi)+5 >>> nppoints = np.vstack((x,y)) >>> poly3 = Polygon(nppoints)7 >>> points = shg.MultiPoint([(0, 0), (1, 1), (2, 0), (1, 0),(0,-2)]) >>> poly1 = Polygon(points) >>> poly2 = Polygon(p=[[3,4,4,3],[1,1,2,2]]) >>> N = 7 >>> phi = np.linspace(0,2*np.pi,N) >>> x = 3*np.cos(phi)+5 >>> y = 3*np.sin(phi)+5 >>> nppoints = np.vstack((x,y)) >>> poly3 = Polygon(nppoints)8 >>> points = shg.MultiPoint([(0, 0), (1, 1), (2, 0), (1, 0),(0,-2)]) >>> poly1 = Polygon(points) >>> poly2 = Polygon(p=[[3,4,4,3],[1,1,2,2]]) >>> N = 7 >>> phi = np.linspace(0,2*np.pi,N) >>> x = 3*np.cos(phi)+5 >>> y = 3*np.sin(phi)+5 >>> nppoints = np.vstack((x,y)) >>> poly3 = Polygon(nppoints)9 |