Given a point (x1, y1, z1) in 3-D and coefficients of the equation of plane, we have to find the foot of perpendicular of a point in a 3 D plane.
Input: a = 1, b = -2, c = 0, d = 0, x = -1, y = 3, z = 4
Output: x2 = 0.4 y2 = 0.2 z2 = 4.0
Input: a = 2, b = -1, c = 1, d = 3, x = 1, y = 3, z = 4
Output: x2 = -1.0 y2 = 4.0 z2 = 3.0
Approach: Equation of plane is given as ax + by + cz + d = 0. Therefore, the direction ratios of the normal to the plane are (a, b, c). Let N be the foot of perpendicular from given point to the given plane so, line PN has directed ratios (a, b, c) and it passes through P(x1, y1, z1).
The equation of line PN will be as:-
(x – x1) / a = (y – y1) / b = (z – z1) / c = k
Hence any point on line PN can be written as:-
x = a * k + x1
y = b * k + y1
z = c * k + z1
since N lies in both line and plane so will satisfy(ax + by + cz + d = 0).
=>a * (a * k + x1) + b * (b * k + y1) + c * (c * k + z1) + d = 0.
=>a * a * k + a * x1 + b * b * k + b * y1 + c * c * k + c * z1 + d = 0.
=>(a * a + b * b + c * c)k = -a * x1 – b * y1 – c * z1 – d.
=>k = (-a * x1 – b * y1 – c * z1 – d) / (a * a + b * b + c * c).
Now, the coordinates of Point N in terms of k will be:-
x2 = a * k + x1
y2 = b * k + y1
z2 = c * k + z1
Below is the implementation of the above:
x2 = 0.4 y2 = 0.2 z2 = 4.0
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.
- Perpendicular distance between a point and a Line in 2 D
- Mirror of a point through a 3 D plane
- Distance between a point and a Plane in 3 D
- Slope of perpendicular to line
- Reflection of a point at 180 degree rotation of another point
- Program to find equation of a plane passing through 3 points
- Program to determine the quadrant of the cartesian plane
- Program to determine the octant of the axial plane
- Program to find the mid-point of a line
- Find the other end point of a line with given one end and mid
- Program to find the Break Even Point
- Check whether given floating point number is even or odd
- Reaching a point using clockwise or anticlockwise movements
- Check whether a point lies inside a sphere or not
- Check if a point lies on or inside a rectangle | Set-2
- C Program to Multiply two Floating Point Numbers
- Minimum distance from a point to the line segment using Vectors
- Check if any point overlaps the given Circle and Rectangle
- Python String Methods | Set 1 (find, rfind, startwith, endwith, islower, isupper, lower, upper, swapcase & title)
- Program to find sum of elements in a given array
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.