3
$\begingroup$

I need to know the angle of an edge using bpy. I need this angle in the x-y plane so if the edge is aligned with the Y axis the angle will be 1.57 radiants (90 degree) and if the edge is aligned with the X axis the angle will be 0. Thanks

$\endgroup$

1 Answer 1

2
$\begingroup$

The raw answer is

import bpy
from mathutils import *
from math import *

v1 = Vector([3,2,0])
v2 = Vector([3,2,1])
C = v2-v1

theta = atan2(C[1], C[0])

print(theta)

If you need to be able to compute this from the currently selected edge of a mesh, let me know and I can upgrade the python.

$\endgroup$
3
  • $\begingroup$ With v1 = Vector([1,1,0]) and v2 = Vector([2,2,0]) should give me 0.78 rad (45°) but give me back 0.0. Thanks anyway! $\endgroup$
    – isar
    Commented Jun 17, 2015 at 20:51
  • 1
    $\begingroup$ OK, i was thinking "from the XY plane" , not "in the XY plane", fixed. $\endgroup$
    – Mutant Bob
    Commented Jun 17, 2015 at 20:59
  • $\begingroup$ Thanks , I was also trying with angle(other, fallback) but the angle was always absolute. Your is a much better way. $\endgroup$
    – isar
    Commented Jun 17, 2015 at 21:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .