Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python calculate angle between two points

from shapely.geometry import Point
import numpy as np
import math

# Function that calculate angle un degre
def calculate_angle(point1, point2):
    angle = math.atan2(point2.y-point1.y, point2.x-point1.x)
    return (math.degrees(angle))

# Point creation (replace random generator by actual number)
point_1 = Point(np.random.random(), np.random.random())
point_2 = Point(np.random.random(), np.random.random())

print(calculate_angle(point_1, point_2))
 
PREVIOUS NEXT
Tagged: #python #calculate #angle #points
ADD COMMENT
Topic
Name
1+6 =