https://github.com/geeksloth/calculate_angle_from_3_points
A simple example to calculate degree angle from 3 given cartesian points in Python
https://github.com/geeksloth/calculate_angle_from_3_points
angle
Last synced: 10 months ago
JSON representation
A simple example to calculate degree angle from 3 given cartesian points in Python
- Host: GitHub
- URL: https://github.com/geeksloth/calculate_angle_from_3_points
- Owner: geeksloth
- Created: 2023-08-01T10:31:36.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-01T12:37:23.000Z (almost 3 years ago)
- Last Synced: 2025-01-30T14:48:47.064Z (over 1 year ago)
- Topics: angle
- Language: Python
- Homepage:
- Size: 92.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# calculate_angle_from_3_points
A simple example to calculate degree angle from 3 given cartesian points in Python

According to the above figure, the points plotted in the result figure are organized as *Red, Green, and Blue* for *P1, P2, and P3* respectively.
The purposed function:
```python3
def calculate_angle(p1x, p1y, p2x, p2y, p3x, p3y):
a = math.dist([p2x,p2y], [p3x,p3y])
b = math.dist([p1x,p1y], [p2x,p2y])
c = math.dist([p1x,p1y], [p3x,p3y])
cos_C = ((a*a) + (b*b) - (c*c)) / (2*a*b)
C_degree = math.acos(cos_C) * (180.0 / math.pi)
return C_degree
```
