Skip to content
Search

Angle

lastmod 2023-01-07created 2022-12-216 edits

In geometry, an angle is the figure formed by two rays sharing a common endpoint. This endpoint is called the vertex of the angle, and the two rays are called the sides of the angle. The quantity expressing how far apart the two sides of an angle are, that is, the size of the angle, is called the angle measure. Strictly speaking, it is the extent of counterclockwise opening from the initial side to the terminal side. An angle usually means one defined on a plane, but a solid angle in three-dimensional space can also be defined.

How to find the angle between two lines

Theory

Find_the_Angle_between_three_points.png

Python

# -*- coding: utf-8 -*-

import math
from typing import NamedTuple

class Point(NamedTuple):
    x: int
    y: int

def angle(a: Point, b: Point, c: Point) -> float:
    ang = math.degrees(math.atan2(c[1]-b[1], c[0]-b[0]) - math.atan2(a[1]-b[1], a[0]-b[0]))
    return ang + 360 if ang < 0 else ang

Using Numpy Library

import numpy as np

a = np.array([6,0])
b = np.array([0,0])
c = np.array([0,6])

ba = a - b
bc = c - b

cosine_angle = np.dot(ba, bc) / (np.linalg.norm(ba) * np.linalg.norm(bc))
angle = np.arccos(cosine_angle)

print np.degrees(angle)

See also

Favorite site

author Zer0 sitemap