I'm having some problems appending two lists programatically. I want to find whether a list of points are laying on an edge or inside the polygon (they can't lay outside).What I have is:
'pedges' is a list of edges forming a closed polygon in Abaqus
'areas' is a list of 'floats'
There is an in-built function called
getDistance
that I am sure works well (from Abaqus)a) If a point lays on the edge then the area at this position is added to
areas_onEdge=[]
b) If a point doesn't lay on the edge then the area at this position is added to
areas_inside=[]
Finally I calculate
sum(areas_inside)/areaShell
I have tried some straight forward code but it doesn't work.
What I am doing wrong?
areaShell=368.97;
areas_onEdge=[]
areas_inside=[]
points=[(923.9,562.0244,0),(923.9,570.8333,0),(914.1,568.6853,0),(923.9,554.1,0),(928.8,568.6853,0),(919,579.2,0)]
areas=[787.2464,368.97,73984.02,42012.99,73984.02,44627.33]
print 'points Inter '.join(map(str,points));
print 'Areas Inter '.join(map(str,areas));
for i in range(0,len(areas)-1):
if p.getDistance(points[i],pedges[i])< 0.0001: #Distance between a point and an edge
areas_onEdge.append(areas[i])
else:
areas_inside.append(areas[i])
result=sum(areas_inside)/areaShell
EDITED
Based on Matheus answer:
for i in range(len(areas)):
is_on_edge = False
for j in range(len(pedges)):
if p.getDistance(points[i], pedges[i]) < 0.0001:
areas_onEdge.append(areas[i])
is_on_edge = True
if not is_on_edge:
areas_inside.append(areas[i])
Would it be possible to zip three lists like this to get the ratio 'ratt'?
for point, area,areaR in zip(pointsInter_proj, areasInter,areasRev):
edges_distances = [p.getDistance(point, pedge) for pedge in pedges]
if min(edges_distances) >=0:
ratt.append(area/areaR);