给定两个点A(x1,y1,z1)和B(x2,y2,z2)以及代表轴(ai + bj + ck)的一组点(a,b,c ) ,任务是找到穿过给定点A和B并平行于给定轴的平面方程。
例子:
Input: x1 = 1, y1 = 2, z1 = 3, x2 = 3, y2 = 4, z2 = 5, a= 6, b = 7, c = 8
Output: 2x + 4y + 2z + 0 = 0
Input: x1 = 2, y1 = 3, z1 = 5, x2 = 6, y2 = 7, z2 = 8, a= 11, b = 23, c = 10.
Output: -29x + 7y + 48z + 0= 0
方法:
从平面A和B上的给定两个点,方向比率线AB的矢量方程式为:
direction ratio = (x2 – x1, y2 – y1, z2 – z1)
自行
平行于给定的轴
。因此,
和
是0,由下式给出:
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.
由上述行列式形成的方程式由下式给出:
(Equation 1)
等式1垂直于线AB ,这意味着它垂直于所需平面。
设平面方程为
(式2)
其中A,B和C是垂直于该平面的平面的方向比率。
由于公式1与公式2相互垂直,因此公式1和2的方向比值平行。然后,平面的系数由下式给出:
A = (b*f – c*e),
B = (a*f – c*d), and
C = (a*e – b*d)
现在,平面和矢量线AB的点积给出D的值为
D = -(A * d – B * e + C * f)
下面是上述方法的实现:
C++
// C++ implementation to find the
// equation of plane which passes
// through two points and parallel
// to a given axis
#include
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;
}
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
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
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
Javascript
-29x + 7y + 48z + 0= 0