The class Grid:
Pointx=[]
Pointy=[]
Pointz=[]
PointNum=0
MinZ=100
MinZRange=0
Def __init__ (self, pNum) :
PointNum=pNum
MinZ=100
MinZRange=0
Def AddPoint (self, pointX, pointY, pointZ) :
Self. Pointx. Append (pointx)
The self. The pointy. Append (pointy)
Self. Pointz. Append (pointz)
The self. The pointNum +=1
Def findMinZ (self) :
Size=self. PointNum
The index=1
If the size==0:
Return index
Z=100.0
The range=0
For I in range (size) :
If self. Pointz [I]
Range=math.h SQRT (self pointx * * 2 + self. [I] pointy [I] * * 2)
Self. MinZ=z
Self. MinZRange=range
Return index
Hor=120
Ver=100
The grid=[]
For I in range (hor) :
The grid. Append ([])
For j in range (ver) :
The grid [I]. Append (grid (0))
PointXYZ=np. Loadtxt (" lidarData. TXT ", encoding='bytes')
I=0
For I in range (27000) :
Range=math. SQRT (pointXYZ [I] [0] * * 2 + pointXYZ [I] [1] * * 2)
GHor=int (math. Atan2 (pointXYZ [1], [I] pointXYZ [I] [0])/3.14 * 180-30)
GVer=int (range/0.25)
If gHor<120 and gHor> 1 the and gVer<100 and gVer> 1:
The grid [gHor] [gVer] AddPoint (pointXYZ [0], [I] pointXYZ [1], [I] pointXYZ [I] [2])
CodePudding user response:
The class Grid:Pointx=[]
Pointy=[]
Pointz=[]
PointNum=0
MinZ=100
MinZRange=0
These all belong to the Grid class variables, not instance variables. Class is equivalent to the c + + classes in static variables,
So, you should put these need variables in __init__ initialization function's parameter list!
CodePudding user response:
So,
The class Grid:
Pointx=[]
Pointy=[]
Pointz=[]
PointNum=0
MinZ=100
MinZRange=0
Def __init__ (self, pNum) :
PointNum=pNum
MinZ=100
MinZRange=0
To:
The class Grid:
Def __init__ (self, pNum) :
The self. The pointNum=pNum
Self. MinZ=100
Self. MinZRange=0
Self. Pointx=[]
Self. Pointy=[]
Self. Pointz=[]
Other places stayed the same!