# Orientation perpendicular to Edge

I have got a mesh that's converted from curve. It has only edges. I need to successively orient one of the objects in the scene to the direction pointed by the blue arrow in the illustration above (perpendicular to the edge and in the direction of the normal of the hypothetical face, formed by the planar vertices). How do I calculate the orientation using python?

• Could you please clarify what you mean by ''successively orient one of the objects in the scene"? What is the context of your situation? How and why are you trying to atchieve this? This might help forming a better solution to your problem. Commented Nov 10, 2018 at 15:02
• @MartinZ Thanks for your interest. It's an animation. The object (or character, if you will) needs to follow path but with the custom orientation. In the first few frames it will be at e0, then e1 and so on. Commented Nov 10, 2018 at 15:37
• You could make an empty follow the curve as a path and then copy it's rotation with a constraint to whatever other object if it does not need to move allong the curve. Would you want a more detailed explanation how to do that? Commented Nov 10, 2018 at 15:56
• Actually, follow path constraint does not orient the empty to the edge (or 'segment' in case of the curve) perpendicular. As far as I could see, it applies the rotation value from matrix_world of the curve object to the constrained object. Secondly, follow constraint needs a curve as path. However, I can't use curve, I need a mesh (converted from curve). Commented Nov 10, 2018 at 16:08
• It can, if you have enough vertices in the curve and align the objects orientation to the first segment. See this I would offer a solution in more detail in an answer but I still cannot understand the wider context and be sure it would not conflict with something I do not know about your situation. For example I do not know what the edge is for so I don't know why it must be mesh object only. It's hard to guess the whole situation, without more detailed explanation. Commented Nov 10, 2018 at 16:29

$$$$\hat{z}: the \space unit \space vector \space along \space z \space axis\\ \vec{e_\perp}:the \space vector \space perpendicular \space to \space edge \space and \space the \space z \space axis\\ \vec{p_1}:position \space of \space first \space vertex \space in \space world \space coordinates\\ \vec{p_2}:position \space of \space second \space vertex \space in \space world \space coordinates\\ \vec{e_1}:vector \space along \space edge\\ \vec{p_2} - \vec{p_1} = \vec{e_1}\\ \hat{z} \times \vec{e_1} = \vec{e_\perp}\\ \vec{e_1} \times \vec{e_\perp} = \vec{desiredDirection}$$$$