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

inicial state

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:

bisect tool

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)

bisect addon 1

last try give me this data:

bmesh data

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

bmesh bisect result

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


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

this is from mesh:

   use_fill=False, clear_inner=False, 
   clear_outer=False, threshold=0.0001, 

and this from bmesh:


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

  • $\begingroup$ see if this is the behavior you are after, if it is i'll update my answer to explain more .blend file $\endgroup$
    – Chebhou
    Mar 30 '15 at 1:19
  • $\begingroup$ @Chebhou thanks for help.... in order to be honest is really difficult to know if your example is what I want.... in a fast reply I think yes... but I'm not sure. thanks again $\endgroup$
    – yhoyo
    Mar 30 '15 at 2:57

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


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

  • $\begingroup$ actually I have a problem with the 3th vector.... I update the post in order to give more information... thanks againg for any data or example $\endgroup$
    – yhoyo
    Mar 30 '15 at 0:16
  • $\begingroup$ Thanks for amazing answer... fast question.. why you add v1.co to v3?? v3 = v3+ vert[1].co $\endgroup$
    – yhoyo
    Mar 31 '15 at 16:51
  • $\begingroup$ you can do that to vert[0], the idea is to get a point behind this vert on the same plane ( camera--->vert------->new_Ponit ), you can substract but it will be the same $\endgroup$
    – Chebhou
    Mar 31 '15 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.