alienhelpdesk.com
projects
Project Petunia
Project petunia. Help us make a music video!
usefull sites
david-laserscanner.com
Home of the david 3d laser scanning software package

finding mesh angles

Here I'll try to explain a method for finding out the angle of a mesh at a specific point/edge in python.
This method can for instance be used to create effects like with: ma baker or ma self  


Finding the angle between two faces in Blender

Now this isn't really complicated.
Lets say you retrieve two faces from Blender's python API that are connected by an edge.
Lets call them face1 and face2 and face1.no retrieves the face normal of face1.

Then we can simply do the following to find the angle:

  1. myAngle = Mathutils.AngleBetweenVecs(face1.no, face2.no)
Display clean python code for copying
myAngle = Mathutils.AngleBetweenVecs(face1.no, face2.no)
The result though is only an angle between 0 and 90 degrees, to find out if that is positive or negative continue reading below.

Finding out whether the angle between two faces is convex or concave 

A lot of the time you also want to know whether the angle is concave or convex (positive or negative).

To get that we get the vector from the midpoint of face1 to the midpoint of face2.
The midpoint of a face is retrieved by getting face1.cent.
Then we get the dot product of the face normal of face1 and the vector we just retrieved.

 

In python that could be:

  1. dotProduct = Mathutils.DotVecs(face1.no, (face2.cent - face1.cent))
Display clean python code for copying
dotProduct = Mathutils.DotVecs(face1.no, (face2.cent - face1.cent))

The resulting dot product will be either positive or negative depending on whether the angle is concave or convex.


 

Swedish proverb
Det var på håret
That was on the hair
Mastering Blender
Mastering Blender
Excellent read by Tony Mullen
Essential Blender
Essential Blender
The official guide!