bisect plane normal (mesh and bmesh) how calc the 3th vector to mathutils.geometry? UPDATE 1:  how calc the 3th vector to mathutils.geometry.normal(vectors)??

After @Chebhou answer I tried my "bisector tool" again... with mesh and bmesh.. now the problem is the 3th vector to calc the plane_normal in mathutils.geometry.normal(vectors)

I think that 3th vector should be align to view..... then I tried with camera and or cursor location with this results:

inicial state is:  download .blend please



the first try with"pure" bisect tool give this data... this is correct then I need reproduce this same data with my addon:

bpy.ops.mesh.bisect(plane_co=(1.57825, 1.50332, -0.165924), plane_no=(0.695399, -0.691791, 0.194541), xstart=167, xend=628, ystart=443, yend=422)


and this result:



second try is with bpy.ops.mesh.bisect that give me this data:

in this case vectors are vertice 1 and vertice 2 selected and the camera location

as you see the cut is good but the location (I think the plane_co) is wrong!

bpy.ops.mesh.bisect(plane_co=(1.36157, 1.69042, 0.804025), plane_no=(-0.660225, 0.660225, -0.358059), use_fill=False, clear_inner=False, clear_outer=False, threshold=0.0001, xstart=404, xend=770, ystart=468, yend=450, cursor=1002)




last try give me this data:



as you see , plane_co is correct but the plane_no is incorrect!



how calc the 3th vector to mathutils.geometry.normal(vectors)??



ORIGINAL POST

Actually I have a problem with the bisect tool... 

this is from mesh:

bpy.ops.mesh.bisect(
   plane_co=plane_co,
   plane_no=plane_no, 
   use_fill=False, clear_inner=False, 
   clear_outer=False, threshold=0.0001, 
   xstart=0, 
   xend=0, 
   ystart=0, 
   yend=0, 
   cursor=1002)


and this from bmesh:

bmesh.ops.bisect_plane(
            bm,
            geom=visible_geom,
            dist=dist,
            plane_co=plane_co, 
            plane_no=plane_no,
            use_snap_center=False,
            clear_outer=False,
            clear_inner=False)


after a lot of effort I thought that  I found the plane_normal equation..... for example for  bmesh:

         v1,v2 = [v.co for v in bm.verts if (v.select == True and v.hide == False)]


        # plane_no math:

        normal = ((v1.y*v2.z)-(v1.z*v2.y)), ((v1.z*v2.x)-(v1.x*v2.z)),((v1.x*v2.y)-(v1.y*v2.x))
        print("thenormal " + str(normal))


        plane_no = normal
        plane_co = v2


but NO!!! 

Actually I know that xstart=0, xend=0, ystart=0, yend=0, are the initial and final location of Operative System Cursor (not 3d blender cursor).. and this data help to  blender in order to calc the plane_co

anyway... I can calc the plane_co because it is any point in the cut plane... but actually I don't know how to calc the plane_normal....  

thanks for any help
The plane normal is the Cross Product of two vectors laying on that plane 


  N = normalize( Vect(P1,P2) X Vect(P1, P3) )    


where Pn is point on the plane 
all these calculation are done using the mathutils.geometry.normal(vectors) which takes 3 points and return the normal vector

Note: Normal direction depends on the Points order



Update

to get the third Point we use the function region_2d_to_vector_3d() which take a 2d coordinates and returns the a normalized vector of the view at this point ,then we add this vector to the point which we used its 2d coordinates to get a new one on the same line of sight (same plane ) , at last we pass the three points to the normal()

v3 =  view3d_utils.region_2d_to_vector_3d(viewport, area.spaces[0].region_3d, co_2d)
v3 = v3+ vert[1].co

normal =  mathutils.geometry.normal(vert[0].co,vert[1].co,v3)


Note you have to pass the the co_2d not co_2d_w to the bisect()

the file