📜  找到穿过两个点并平行于给定轴的平面方程

📅  最后修改于: 2021-04-22 01:11:01             🧑  作者: Mango

给定两个点A(x1,y1,z1)B(x2,y2,z2)以及代表轴(ai + bj + ck)的一组点(a,b,c ) ,任务是找到穿过给定点AB并平行于给定轴的平面方程。
例子:

方法:
从平面A和B上的给定两个点,方向比率线AB的矢量方程式为:

自行

\overrightarrow{AB}

平行于给定的轴

(ai + bj + ck)

。因此,

\overrightarrow{AB}

(ai + bj + ck)

是0,由下式给出:

由上述行列式形成的方程式由下式给出:

等式1垂直于线AB ,这意味着它垂直于所需平面。
设平面方程为

Ax + By + Cz = D

(式2)
其中A,B和C是垂直于该平面的平面的方向比率。
由于公式1公式2相互垂直,因此公式1和2的方向比值平行。然后,平面的系数由下式给出:

现在,平面和矢量线AB的点积给出D的值为

下面是上述方法的实现:

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