Featured post

new redirect for blender.org bpy docs.

http://www.blender.org/api/blender_python_api_current/ As of 10/11 november 2015 we can now link to the current api docs and not be worr...

May 17, 2011

Blender 2.5 Python Finding the Normal Vector

given any three coordinates we can use mathutils.geometry to calculate the Normal Direction that would result if we turned the coordinates into a Trigon. The direction of the Normal depends on what order you take the coordinates. If all vertices in question had the same Z value it would mean they are on the same plane, but we would not yet know what direction the face is 'pointing at'. The direction of the Normal depends on the order in which we pass it the vertices/coordinates. [add openGL link here]

>>> help(mathutils.geometry.normal) gives instructions about using the function.

Example usage is this

import bpy
from mathutils import Vector, geometry

co_1 = Vector((-1.3349171876907349, -0.4734605848789215, 0.3062398433685303))
co_2 = Vector((0.6650824546813965, -0.4734615385532379, 0.3062398433685303))
co_3 = Vector((0.6698348522186279, 0.9469220638275146, -0.6124801635742188))
# presume this to be a clockwise sequence
# note the different result from counter clockwise coordinate sequence