xlist2 = xlist[len(xlist) / 2:] ylist2 = ylist[len(ylist) / 2:] zlist2 = zlist[len(zlist) / 2:] atoms2 = atoms[len(atoms) / 2:] if len(nanaparticles) != 2: print "Only two nanoparticles can be used" exit(1) DITS1 = 2.6 DIST2 = 12.6 nanop1 = nanaparticles[0] ptop, pbot = nanop1.get_ptop_and_bottom() l1 = line.line3d() l1.set_two_point(ptop, pbot) p1, p2, p3, p4 = nanop1.get_middle_points() mdplane = plane.plane(p1, p2, p3) group1_np1 = [] group2_np1 = [] group3_np1 = [] allnp1 = [] for i in range(len(xlist1)): p = point.point(xlist1[i], ylist1[i], zlist1[i]) dist = mdplane.get_distance(p) * mdplane.check_point_side(p) if dist < DITS1: group1_np1.append((p.get_x(), p.get_y(), p.get_z()))
exit(1) nanoparticles = [] botx, topx, boty, topy, botz, topz = \ nanoparticle.file_to_nanoparticle_list(filename, nanoparticles) if (botx >= topx) or (boty >= topy) or \ (boty >= topy): print "Error Invalid BOX" exit() minbox_x = 100000.0 maxbox_x = -100000.0 minbox_y = 100000.0 maxbox_y = -100000.0 minbox_z = 100000.0 maxbox_z = -100000.0 if len(nanoparticles) != 2: print "Error " exit(1) p1top, p1bottom = nanoparticles[0].get_ptop_and_bottom() p2top, p2bottom = nanoparticles[1].get_ptop_and_bottom() l3d = line.line3d() angle = l3d.get_angle_two_line(p1top, p1bottom, p2top, p2bottom) print angle
def generate_point_inside_poly(p1, p2, p3, p4, step, psurface_list, label): polypoint = [] polypoint.append(p1) polypoint.append(p2) polypoint.append(p3) polypoint.append(p4) # i 4 punti devono essere ordinati oraio o antiorario e' indifferente # calcolo il lato piu' lungo d = [] d.append(p1.get_distance_from(p2)) d.append(p2.get_distance_from(p3)) d.append(p3.get_distance_from(p4)) d.append(p4.get_distance_from(p1)) idx = 0 for i in range(1,4): if (d[i] > d[i-1]): idx = i #print "Max: ", d[idx] # forse meglio indicare lo step cosi' da avere uniformita' di punti numofp = int(d[idx] / step) if (numofp == 0): print >> sys.stderr, "Step too big ", d[idx] , " and ", step return B = point.point() C = point.point() l = line.line3d() if idx == 0: l.set_two_point(p1, p2) B.set_coordinates(p2.get_x(), p2.get_y(), p2.get_z()) C.set_coordinates(p3.get_x(), p3.get_y(), p3.get_z()) elif idx == 1: l.set_two_point(p2, p3) B.set_coordinates(p3.get_x(), p3.get_y(), p3.get_z()) C.set_coordinates(p4.get_x(), p4.get_y(), p4.get_z()) elif idx == 2: l.set_two_point(p3, p4) B.set_coordinates(p4.get_x(), p4.get_y(), p4.get_z()) C.set_coordinates(p1.get_x(), p1.get_y(), p1.get_z()) elif idx == 3: l.set_two_point(p4, p1) B.set_coordinates(p1.get_x(), p1.get_y(), p1.get_z()) C.set_coordinates(p2.get_x(), p2.get_y(), p2.get_z()) # questi punti li genero lungo il lato piu' lungo plist = l.generate_equi_point(numofp) for p in plist: p.set_label(label) psurface_list.append(p) #print psurface_list[-1].get_label() # http://www.youtube.com/watch?v=HmMJGcHV9Oc # equazione vettoriale del piano # # -- -- -- -- # OP = OA + a * AB + b * BC # # dove O origine P punto che voglio e A B C li definisco # a seconda del segmento che ho preso sopra # # A---------------------B # | # | # | # C # mi muovo lungo BC step by step # posso usare sempre le rette cambio nella line3d il valore di a # e di b quindi A diventa ogni volta il punto in plist, e b diventa # il vettore paralleloa BC, dovrebbe bastare appunto BC. lBC = line.line3d() lBC.set_b(C-B) for p in plist: lBC.set_a(p) plistBC = lBC.generate_equi_point(numofp) for pBC in plistBC: diff = math.fabs(angle_sum_poly(polypoint, pBC) - TWOPI) if (diff < 1e-10): pBC.set_label(label) psurface_list.append(pBC) #print psurface_list[-1].get_label() return