I never used python but now I need a code to do this calculation:
I'm doing this:
math.atan(math.fabs( !Y2! - !Y1!)/math.fabs( !X2! - !X1!) )*(180/math.pi)
2 Answers 2
Could you do something like:
Pre-Logic Script code:
def mathFunction(y1, y2, x1, x2):
return math.Atan(math.fabs(y2-y1) / math.fabs(x2-x1)) * (180/math.pi)
Field = (on the bottom)...populate with your fields for y1,y2,x1,x2
mathFunction(!FIELDY1!, !FIELDY2!,!FIELDX1!,!FIELDX2!)
See Python doc on the math module.
Here is a screenshot
answered Apr 16, 2015 at 12:13
Are you looking for atan2 ? It's precisely meant to deal with this signs mess.
Explore related questions
See similar questions with these tags.
lang-py