Given coordinates of three points A(x1, y1, z1), B(x2, y2, z2) and C(x3, y3, z3) in a 3D plane, where B is the intersection point of line AB and BC, the task is to find angle between lines AB and BC.
Input: x1 = 1, y1 = 3, z1 = 3; x2 = 3, y2 = 4, z2 = 5; x3 = 5, y3 = 6, z3 = 9;
Input: x1 = 10, y1 = 10, z1 = 10; x2 = 0, y2 = 0, z2 = 0; x3 = 15, y3 = 10, z3 = 15;
- Find the equation of lines AB and BC with the given coordinates in terms of direction ratios as:
AB = (x1 – x2)i + (y1 – y2)j + (z1 – z2)k
BC = (x3 – x2)i + (y3 – y2)j + (z3 – z2)k
- Use the formula for cos Θ for the two direction ratios of lines AB and BC to find the cosine of the angle between lines AB and BC as:
AB.BC is the dot product of direction ratios AB and BC.
|AB| is the magnitude of line AB
|BC| is the magnitude of line BC
Suppose there are two direction ratios:
A = ai + bj + ck B = xi + yj + zk
Dot Product(A.B) = a*x + b*y + c*z
magnitude of A = |A| =
magnitude of B = |B| =
- The cosine of the angle calculated gives the cosine value in radian. To find the angle multiply the cosine value by (180/Π).
Below is the implementation of the above approach:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Nth angle of a Polygon whose initial angle and per angle increment is given
- Angle between a chord and a tangent when angle in the alternate segment is given
- Angle subtended by the chord when the angle subtended by another chord of same length is given
- Exterior angle of a cyclic quadrilateral when the opposite interior angle is given
- Angle subtended by the chord to center of the circle when the angle subtended by the another equal chord of a congruent circle is given
- Program to calculate angle on circumference subtended by the chord when the central angle subtended by the chord is given
- Area of Triangle using Side-Angle-Side (length of two sides and the included angle)
- Print N lines of 4 numbers such that every pair among 4 numbers has a GCD K
- Calculate the angle between hour hand and minute hand
- Angle between two Planes in 3D
- Angle between 3 given vertices in a n-sided regular polygon
- Length of diagonal of a parallelogram using adjacent sides and angle between them
- Distance between two parallel lines
- Find other two sides of a right angle triangle
- Find if it's possible to rotate the page by an angle or not.
- Maximum number of squares that can fit in a right angle isosceles triangle
- Arc length from given Angle
- Program to find the Interior and Exterior Angle of a Regular Polygon
- Check if it is possible to create a polygon with a given angle
- Area of a largest square fit in a right angle triangle
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.