We have four points: a
, b
, c
and d
. We only know length of line cd
and line ab
. We also know that points c
and d
have same x
coordinate, also points a
and b
have same x
coordinate. Lines cd
and ab
are parallel. How can I find angle (marked as green) between lines ca
and line db
? Please provide example of calculations.
[Math] Calculate angle between two lines
geometry
Best Answer
Given the points with their coordinates $a_x, a_y ... d_x, d_y$, you can compute the angle of each line to the x-axis (using the arcustangens function), and then just compute the difference between these angles.
So you can compute the angles
$\alpha_0 = atan2(c_y-a_y, c_x-a_x)$
and
$\alpha_1 = atan2(d_y-b_y, d_x-b_x)$
(see the wikipedia link for the definition of the $atan2$ function).
The angle between the lines is then simply $\alpha_1-\alpha_0$
EDIT: The example:
Now compute
$\alpha_0 = atan2(c_y-a_y, c_x-a_x) = atan2(3, -100)$ $\alpha_1 = atan2(d_y-b_y, d_x-b_x) = atan2(0, -100)$
According to the cases described in this image from wikipedia:
We have
$\alpha_0 = atan(3/-100) + \pi \approx 3.1116016487329152$
$\alpha_1 = atan(0/-100) + \pi \approx 3.141592653589793$
And the angle is then the difference
$\alpha = \alpha_1 - \alpha_0 \approx 0.02999100485687789 \approx 1.718°$