I have a list of angles, i.e. 84.81, 79.09, 72.95, 65.81, 59.45, 53.13, 47.73, 43.45, 43.09, which are calculated based on three vertices in 2D. So, the angles are the angles between three points.
def angle3P(p1, p2, p3):
# get distances
a = dist2D(p3, p1);
b = dist2D(p3, p2);
c = dist2D(p1, p2);
# calculate angle // assume a and b are nonzero
# (law of cosines)
numer = c**2 - a**2 - b**2;
denom = -2 * a * b;
if denom == 0:
denom = 0.000001;
rads = math.acos(numer / denom);
degs = math.degrees(rads);
# check if past 180 degrees
if p1[1] > p3[1]:
degs = 360 - degs;
return degs;
I’d now like to plot vertices for each angle based on this with the starting point being (0,0). I know the distance between the points which is equal for all. But I have no idea how to calculate x,y coordinates for of the angles. Not looking to reference previous x,y positions at all.
points = list()
points.append([0,0])
points.append([distance,distance])
for angle in angles:
angle = float(angle)
A = points[len(points)-2]
B = points[len(points)-1]
xPos = 0 # Don't know how to calculate this.
yPos = 0
points.append([xPos, yPos])
I’m working in Python.
It is a closed contour, so ideally I can remove the distance point added at the start.
See attached an example of the original contour points:
Contour points represent the points used to calculate angles:
Calculating the angles:
6