Hướng dẫn polygon in python - đa giác trong python

>>> %pylab inline
Populating the interactive namespace from numpy and matplotlib

Nội dung chính ShowShow

  • âm mưu đa giác
  • buildgv ()¶
  • Các lớp Geomview
  • Geomvect class¶
  • geomomase¶
  • điểm trong
  • âm mưu hộp
  • Các chức năng tiện ích¶
  • góc cạnh
  • DPTSEG (P, PT, PH) ¶
  • sự biểu lộ
  • Ptonseg (PTA, PHE, PT) ¶
  • giao nhau¶
  • Các chức năng hữu ích

  File "", line 2
    Populating the interactive namespace from numpy and matplotlib
                 ^
SyntaxError: invalid syntax
>>> 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 trong

Geomvect 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 "", line 2
    Populating the interactive namespace from numpy and matplotlib
                 ^
SyntaxError: invalid syntax
0
  File "", line 2
    Populating the interactive namespace from numpy and matplotlib
                 ^
SyntaxError: invalid syntax
1
  File "", line 2
    Populating the interactive namespace from numpy and matplotlib
                 ^
SyntaxError: invalid syntax
2
  File "", line 2
    Populating the interactive namespace from numpy and matplotlib
                 ^
SyntaxError: invalid syntax
3
  File "", line 2
    Populating the interactive namespace from numpy and matplotlib
                 ^
SyntaxError: invalid syntax
4

âm mưu hộp

  File "", line 2
    Populating the interactive namespace from numpy and matplotlib
                 ^
SyntaxError: invalid syntax
5

Các chức năng tiện ích¶

góc cạnh

DPTSEG (P, PT, PH) ¶

  File "", line 2
    Populating the interactive namespace from numpy and matplotlib
                 ^
SyntaxError: invalid syntax
6
  File "", line 2
    Populating the interactive namespace from numpy and matplotlib
                 ^
SyntaxError: invalid syntax
7

sự biểu lộ

  File "", line 2
    Populating the interactive namespace from numpy and matplotlib
                 ^
SyntaxError: invalid syntax
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 shg
2

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 shg
3
>>> from pylayers.util.geomutil import *
>>> from pylayers.util.plotutil import *
>>> import matplotlib.pyplot as plt
>>> import shapely.geometry as shg
4

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 shg
5
>>> from pylayers.util.geomutil import *
>>> from pylayers.util.plotutil import *
>>> import matplotlib.pyplot as plt
>>> import shapely.geometry as shg
6

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 shg
7
>>> from pylayers.util.geomutil import *
>>> from pylayers.util.plotutil import *
>>> import matplotlib.pyplot as plt
>>> import shapely.geometry as shg
8
>>> from pylayers.util.geomutil import *
>>> from pylayers.util.plotutil import *
>>> import matplotlib.pyplot as plt
>>> import shapely.geometry as shg
9
>>> 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 shg
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)
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

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.