1
$\begingroup$

I have a set of vertices for a BMFace that I'm trying to rotate around the x-axis but in the face's normal orientation. Currently I'm doing:

c = face.calc_center_median()
T = Matrix.Translation(-c)
rot_angle = 0.25
rot_axis = (1, 0, 0)
bmesh.ops.rotate(
    bm,
    space=T,
    matrix=Matrix.Rotation(rot_angle, 4, rot_axis),
    verts=face.verts
)

My guess is that I can get the normal x-axis through face.normal but I'm not sure what to do next or how to best formulate the question to learn more. There are an infinite number of possible x-axes orthogonal to face.normal, aren't there?

$\endgroup$
0
$\begingroup$

After some reading I managed a solution, but I'm not sure how robust it is:

tangent = face.calc_tangent_edge_pair()
rot_axis = -face.normal.cross(tangent)

The tangent is one of the other normal axes and from that the last axis is calculated as its cross product with the face's normal.

This seems dependent on which edges are the longest (the documentation for BMFace.calc_tangent_edge_pair says: "Return face tangent based on the two longest disconnected edges."), so I imagine there's a better way to approach this!

$\endgroup$

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.