Hướng dẫn polygon in python - đa giác trong python
Ngày đăng:
16/11/2022
Trả lời:
0
Lượt xem:
80
>>> %pylab inline Populating the interactive namespace from numpy and matplotlib Nội dung chính ShowShow 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. 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 ()¶Các lớp Geomview Geomvect class¶ geomomase¶điểm trongGeomvect class¶geomomase¶ geomomase¶điểm trong >>> 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 trongâm mưu hộp >>> gv1 = GeomVect('test1') >>> gv1.points(np.random.rand(3,10)) >>> #gv1.show3() Các chức năng tiện ích¶ >>> geo = Geomoff('test2') >>> pt = poly3.ndarray().T >>> pt1 = np.hstack((pt,np.zeros((7,1)))) góc cạnh 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ạnhDPTSEG (P, PT, PH) ¶ File "6 File "7 sự biểu lộFile "8 DPTSEG (P, PT, PH) ¶sự biểu lộ Ptonseg (PTA, PHE, PT) ¶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) ¶giao nhau¶ >>> 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 Các chức năng hữu ích>>> 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¶Các chức năng hữu ích >>> 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 íchGeomutil 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. |