I have 2 sets of points, say AB and CD. They may or may not be in a straight line. I know their x, y co-ordinates and the angles they make with the horizontal plane. I need to adjust the angle that line AB forms with the horizontal plane in such a way that the points AB are perfectly aligned with CD. Meaning, they form a trapezoid. The image will make it clearer:
Any ideas as how to find the required angle between AB and the horizontal plane? The distance between any of the points should not be changed.
Important: Since I'll be implementing the solution in a browser, all the co-ordinates are read from top, left = 0, 0. I'm rotating around the center, in a clockwise direction.