![]() |
VOOZH | about |
Given two integers M1 and M2 representing the slope of two lines intersecting at a point, the task is to find the angle between these two lines.
Examples:
Input: M1 = 1.75, M2 = 0.27
Output: 45.1455 degreesInput: M1 = 0.5, M2 = 1.75
Output: 33.6901 degrees
Approach: If ? is the angle between the two intersecting lines, then the angle ? can be calculated by:
tan? = |(M2 - M1) / (1 + M1 * M2)|
=> ? = tan-1( |(M2 - M1) / (1 + M1 * M2)| )
Follow the steps below to solve the problem:
Below is the implementation of the above approach:
45.1455
Time Complexity: O(1)
Auxiliary Space: O(1)