Given two points **A(x1, y1, z1)** and **B(x2, y2, z2)** and a set of points (a, b, c) which represent the axis **(ai + bj + ck)**, the task is to find the equation of plane which passes through the given points **A** and **B** and parallel to the given axis.**Examples:**

Input:x1 = 1, y1 = 2, z1 = 3, x2 = 3, y2 = 4, z2 = 5, a= 6, b = 7, c = 8Output:2x + 4y + 2z + 0 = 0Input:x1 = 2, y1 = 3, z1 = 5, x2 = 6, y2 = 7, z2 = 8, a= 11, b = 23, c = 10.Output:-29x + 7y + 48z + 0= 0

**Approach:**

From the given two points on plane A and B, The directions ratios a vector equation of line **AB** is given by:

direction ratio = (x2 – x1, y2 – y1, z2 – z1)

Since the line

is parallel to the given axis

. Therefore, the cross-product of

and

is 0 which is given by:

where,

d, e, and f are the coefficient of vector equation of line AB i.e.,

d = (x2 – x1),

e = (y2 – y1), and

f = (z2 – z1)

and a, b, and c are the coefficient of given axis.

The equation formed by the above determinant is given by:

(Equation 1)

**Equation 1** is perpendicular to the line **AB** which means it is perpendicular to the required plane.

Let the Equation of the plane is given by

**(Equation 2)**

where **A, B, and C** are the direction ratio of the plane perpendicular to the plane.

Since **Equation 1** is **Equation 2** are perpendicular to each other, therefore the value of the direction ratio of **Equation 1 & 2** are parallel. Then the coefficient of the plane is given by:

A = (b*f – c*e),

B = (a*f – c*d), and

C = (a*e – b*d)

Now dot product of plane and vector line AB gives the value of D as

D = -(A * d – B * e + C * f)

Below is the implementation of the above approach:

## C++

`// C++ implementation to find the ` `// equation of plane which passes ` `// through two points and parallel ` `// to a given axis ` ` ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `void` `findEquation(` `int` `x1, ` `int` `y1, ` `int` `z1, ` ` ` `int` `x2, ` `int` `y2, ` `int` `z2, ` ` ` `int` `d, ` `int` `e, ` `int` `f) ` `{ ` ` ` ` ` `// Find direction vector ` ` ` `// of points (x1, y1, z1) ` ` ` `// and (x2, y2, z2) ` ` ` `double` `a = x2 - x1; ` ` ` `double` `b = y2 - y1; ` ` ` `double` `c = z2 - z1; ` ` ` ` ` `// Values that are calculated ` ` ` `// and simplified from the ` ` ` `// cross product ` ` ` `int` `A = (b * f - c * e); ` ` ` `int` `B = (a * f - c * d); ` ` ` `int` `C = (a * e - b * d); ` ` ` `int` `D = -(A * d - B * e + C * f); ` ` ` ` ` `// Print the equation of plane ` ` ` `cout << A << ` `"x + "` `<< B << ` `"y + "` ` ` `<< C << ` `"z + "` `<< D << ` `"= 0"` `; ` `} ` ` ` `// Driver Code ` `int` `main() ` `{ ` ` ` ` ` `// Point A ` ` ` `int` `x1 = 2, y1 = 3, z1 = 5; ` ` ` ` ` `// Point B ` ` ` `int` `x2 = 6, y2 = 7, z2 = 8; ` ` ` ` ` `// Given axis ` ` ` `int` `a = 11, b = 23, c = 10; ` ` ` ` ` `// Function Call ` ` ` `findEquation(x1, y1, z1, ` ` ` `x2, y2, z2, ` ` ` `a, b, c); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java implementation to find the ` `// equation of plane which passes ` `// through two points and parallel ` `// to a given axis ` `import` `java.util.*; ` ` ` `class` `GFG{ ` ` ` `static` `void` `findEquation(` `int` `x1, ` `int` `y1, ` `int` `z1, ` ` ` `int` `x2, ` `int` `y2, ` `int` `z2, ` ` ` `int` `d, ` `int` `e, ` `int` `f) ` `{ ` ` ` ` ` `// Find direction vector ` ` ` `// of points (x1, y1, z1) ` ` ` `// and (x2, y2, z2) ` ` ` `double` `a = x2 - x1; ` ` ` `double` `b = y2 - y1; ` ` ` `double` `c = z2 - z1; ` ` ` ` ` `// Values that are calculated ` ` ` `// and simplified from the ` ` ` `// cross product ` ` ` `int` `A = (` `int` `)(b * f - c * e); ` ` ` `int` `B = (` `int` `)(a * f - c * d); ` ` ` `int` `C = (` `int` `)(a * e - b * d); ` ` ` `int` `D = -(` `int` `)(A * d - B * e + C * f); ` ` ` ` ` `// Print the equation of plane ` ` ` `System.out.println(A + ` `"x + "` `+ B + ` `"y + "` `+ ` ` ` `C + ` `"z + "` `+ D + ` `"= 0 "` `); ` `} ` ` ` `// Driver code ` `public` `static` `void` `main(String[] args) ` `{ ` ` ` ` ` `// Point A ` ` ` `int` `x1 = ` `2` `, y1 = ` `3` `, z1 = ` `5` `; ` ` ` ` ` `// Point B ` ` ` `int` `x2 = ` `6` `, y2 = ` `7` `, z2 = ` `8` `; ` ` ` ` ` `// Given axis ` ` ` `int` `a = ` `11` `, b = ` `23` `, c = ` `10` `; ` ` ` ` ` `// Function Call ` ` ` `findEquation(x1, y1, z1, ` ` ` `x2, y2, z2, ` ` ` `a, b, c); ` `} ` `} ` ` ` `// This code is contributed by Pratima Pandey ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 implementation ` `# to find the equation ` `# of plane which passes ` `# through two points and ` `# parallel to a given axis ` `def` `findEquation(x1, y1, z1, ` ` ` `x2, y2, z2, ` ` ` `d, e, f): ` ` ` ` ` `# Find direction vector ` ` ` `# of points (x1, y1, z1) ` ` ` `# and (x2, y2, z2) ` ` ` `a ` `=` `x2 ` `-` `x1 ` ` ` `b ` `=` `y2 ` `-` `y1 ` ` ` `c ` `=` `z2 ` `-` `z1 ` ` ` ` ` `# Values that are calculated ` ` ` `# and simplified from the ` ` ` `# cross product ` ` ` `A ` `=` `(b ` `*` `f ` `-` `c ` `*` `e) ` ` ` `B ` `=` `(a ` `*` `f ` `-` `c ` `*` `d) ` ` ` `C ` `=` `(a ` `*` `e ` `-` `b ` `*` `d) ` ` ` `D ` `=` `-` `(A ` `*` `d ` `-` `B ` `*` ` ` `e ` `+` `C ` `*` `f) ` ` ` ` ` `# Print the equation of plane ` ` ` `print` `(A, ` `"x + "` `, B, ` `"y + "` `, ` ` ` `C, ` `"z + "` `, D, ` `"= 0"` `) ` ` ` `# Driver Code ` `if` `__name__ ` `=` `=` `"__main__"` `: ` ` ` ` ` `# Point A ` ` ` `x1 ` `=` `2` ` ` `y1 ` `=` `3` ` ` `z1 ` `=` `5` `; ` ` ` ` ` `# Point B ` ` ` `x2 ` `=` `6` ` ` `y2 ` `=` `7` ` ` `z2 ` `=` `8` ` ` ` ` `# Given axis ` ` ` `a ` `=` `11` ` ` `b ` `=` `23` ` ` `c ` `=` `10` ` ` ` ` `# Function Call ` ` ` `findEquation(x1, y1, z1, ` ` ` `x2, y2, z2, ` ` ` `a, b, c) ` ` ` `# This code is contributed by Chitranayal` |

*chevron_right*

*filter_none*

## C#

`// C# implementation to find the ` `// equation of plane which passes ` `// through two points and parallel ` `// to a given axis ` `using` `System; ` `class` `GFG{ ` ` ` `static` `void` `findEquation(` `int` `x1, ` `int` `y1, ` `int` `z1, ` ` ` `int` `x2, ` `int` `y2, ` `int` `z2, ` ` ` `int` `d, ` `int` `e, ` `int` `f) ` `{ ` ` ` ` ` `// Find direction vector ` ` ` `// of points (x1, y1, z1) ` ` ` `// and (x2, y2, z2) ` ` ` `double` `a = x2 - x1; ` ` ` `double` `b = y2 - y1; ` ` ` `double` `c = z2 - z1; ` ` ` ` ` `// Values that are calculated ` ` ` `// and simplified from the ` ` ` `// cross product ` ` ` `int` `A = (` `int` `)(b * f - c * e); ` ` ` `int` `B = (` `int` `)(a * f - c * d); ` ` ` `int` `C = (` `int` `)(a * e - b * d); ` ` ` `int` `D = -(` `int` `)(A * d - B * e + C * f); ` ` ` ` ` `// Print the equation of plane ` ` ` `Console.Write(A + ` `"x + "` `+ B + ` `"y + "` `+ ` ` ` `C + ` `"z + "` `+ D + ` `"= 0 "` `); ` `} ` ` ` `// Driver code ` `public` `static` `void` `Main() ` `{ ` ` ` ` ` `// Point A ` ` ` `int` `x1 = 2, y1 = 3, z1 = 5; ` ` ` ` ` `// Point B ` ` ` `int` `x2 = 6, y2 = 7, z2 = 8; ` ` ` ` ` `// Given axis ` ` ` `int` `a = 11, b = 23, c = 10; ` ` ` ` ` `// Function Call ` ` ` `findEquation(x1, y1, z1, ` ` ` `x2, y2, z2, ` ` ` `a, b, c); ` `} ` `} ` ` ` `// This code is contributed by Code_Mech ` |

*chevron_right*

*filter_none*

**Output:**

-29x + 7y + 48z + 0= 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.

## Recommended Posts:

- Program to find equation of a plane passing through 3 points
- Program to check if the points are parallel to X axis or Y axis
- Program to calculate area of inner circle which passes through center of outer circle and touches its circumference
- Count rectangles generated in a given rectangle by lines drawn parallel to X and Y axis from a given set of points
- Check if a line passes through the origin
- Count of Squares that are parallel to the coordinate axis from the given set of N points
- Number of lines from given N points not parallel to X or Y axis
- Count of Right-Angled Triangle formed from given N points whose base or perpendicular are parallel to X or Y axis
- Maximum number of region in which N non-parallel lines can divide a plane
- Equation of straight line passing through a given point which bisects it into two equal line segments
- Find the point on X-axis from given N points having least Sum of Distances from all other points
- Minimum number of points to be removed to get remaining points on one side of axis
- Find whether only two parallel lines contain all coordinates points or not
- Maximum distance between two points in coordinate plane using Rotating Caliper's Method
- Number of triangles in a plane if no more than two points are collinear
- Mirror of a point through a 3 D plane
- Count of rectangles possible from N and M straight lines parallel to X and Y axis respectively
- Count squares possible from M and N straight lines parallel to X and Y axis respectively
- Find Four points such that they form a square whose sides are parallel to x and y axes
- Find X and Y intercepts of a line passing through the given points

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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.