Created
October 30, 2022 00:29
-
-
Save victormurcia/321ec5747b9401737f0214f497bcbfaf to your computer and use it in GitHub Desktop.
get blade angle w.r.t. substrate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_angle(): | |
#Get line coordinates | |
x1 = cs.points[0][0];y1 = cs.points[0][1] | |
x2 = cs.points[1][0];y2 = cs.points[1][1] | |
x3 = cs.points[2][0];y3 = cs.points[2][1] | |
x4 = cs.points[3][0];y4 = cs.points[3][1] | |
#Use coordinates to get components of vectors | |
vx1 = (x1-x2);vy1 = (y1-y2) | |
vx2 = (x4-x3);vy2 = (y4-y3) | |
#Vectors | |
v1 = [vx1,vy1];v2 = [vx2,vy2] | |
#Vector magnitudes | |
mag1 = np.linalg.norm(v1);mag2 = np.linalg.norm(v2) | |
#Calculate angle between vectors | |
dot = np.dot(v1,v2) | |
magP = (mag1*mag2) | |
quot = dot/magP | |
angle = round(math.degrees(np.arccos(quot)),1) | |
print(angle) | |
return angle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment