Dados tres puntos (x1, y1, z1), (x2, y2, z2), (x3, y3, z3). La tarea es encontrar la ecuación del plano que pasa por estos 3 puntos.
Ejemplos:
Entrada: x1 = -1 y1 = w z1 = 1
x2 = 0 y2 = -3 z2 = 2
x3 = 1 y3 = 1 z3 = -4
Salida: la ecuación del plano es 26 x + 7 y + 9 z + 3 = 0
Entrada: x1 = 2, y1 = 1, z1 = -1, 1
x2 = 0, y2 = -2, z2 = 0
x3 = 1, y3 = -1, z3 = 2
Salida: la ecuación del plano es -7 x + 5 y + 1 z + 10 = 0.
Planteamiento: Sean P, Q y R los tres puntos con coordenadas (x1, y1, z1), (x2, y2, z2), (x3, y3, z3) respectivamente. Entonces la ecuación del plano es a * (x – x0) + b * (y – y0) + c * (z – z0) = 0 , donde a, b, c son relaciones de dirección normal al plano y (x0, y0, z0) son las coordenadas de cualquier punto (es decir, P, Q o R) que pasa por el plano. Para encontrar las relaciones de dirección de la normal al plano, tome dos vectores cualesquiera en el plano, sea el vector PQ, el vector PR.
=> Vector PQ = (x2 - x1, y2 - y1, z2 - z1) = (a1, b1, c1). => Vector PR = (x3 - x1, y3 - y1, z3 - z1) = (a2, b2, c2).
El vector normal a este plano será vector PQ x vector PR.
=> PQ X PR = (b1 * c2 - b2 * c1) i + (a2 * c1 - a1 * c2) j + (a1 * b2 - b1 *a2) k = ai + bj + ck.
Las relaciones de dirección del vector normal serán a, b, c. Tomando cualquier punto de P, Q o R, sea su coordenada (x0, y0, z0). Entonces la ecuación del plano que pasa por un punto (x0, y0, z0) y que tiene relaciones de dirección a, b, c será
=> a * (x - x0) + b * (y - y0) + c * (z - z0) = 0. => a * x - a * x0 + b * y - b * y0 + c * z - c * z0 = 0. => a * x + b * y + c * z + (- a * x0 - b * y0 - c * z0) = 0.
A continuación se muestra la implementación del enfoque anterior:
C++
// C++ program to find equation of a plane // passing through given 3 points. #include <bits/stdc++.h> #include<math.h> #include <iostream> #include <iomanip> using namespace std; // Function to find equation of plane. void equation_plane(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3) { float a1 = x2 - x1; float b1 = y2 - y1; float c1 = z2 - z1; float a2 = x3 - x1; float b2 = y3 - y1; float c2 = z3 - z1; float a = b1 * c2 - b2 * c1; float b = a2 * c1 - a1 * c2; float c = a1 * b2 - b1 * a2; float d = (- a * x1 - b * y1 - c * z1); std::cout << std::fixed; std::cout << std::setprecision(2); cout << "equation of plane is " << a << " x + " << b << " y + " << c << " z + " << d << " = 0."; } // Driver Code int main() { float x1 =-1; float y1 = 2; float z1 = 1; float x2 = 0; float y2 =-3; float z2 = 2; float x3 = 1; float y3 = 1; float z3 =-4; equation_plane(x1, y1, z1, x2, y2, z2, x3, y3, z3); return 0; } // This code is contributed // by Amber_Saxena.
C
// C program to find equation of a plane // passing through given 3 points. #include<stdio.h> // Function to find equation of plane. void equation_plane(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3) { float a1 = x2 - x1; float b1 = y2 - y1; float c1 = z2 - z1; float a2 = x3 - x1; float b2 = y3 - y1; float c2 = z3 - z1; float a = b1 * c2 - b2 * c1; float b = a2 * c1 - a1 * c2; float c = a1 * b2 - b1 * a2; float d = (- a * x1 - b * y1 - c * z1); printf("equation of plane is %.2f x + %.2f" " y + %.2f z + %.2f = 0.",a,b,c,d); return; } // Driver Code int main() { float x1 =-1; float y1 = 2; float z1 = 1; float x2 = 0; float y2 =-3; float z2 = 2; float x3 = 1; float y3 = 1; float z3 =-4; equation_plane(x1, y1, z1, x2, y2, z2, x3, y3, z3); return 0; } // This code is contributed // by Amber_Saxena.
Java
// Java program to find equation // of a plane passing through // given 3 points. import java .io.*; class GFG { // Function to find equation of plane. static void equation_plane(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3) { float a1 = x2 - x1; float b1 = y2 - y1; float c1 = z2 - z1; float a2 = x3 - x1; float b2 = y3 - y1; float c2 = z3 - z1; float a = b1 * c2 - b2 * c1; float b = a2 * c1 - a1 * c2; float c = a1 * b2 - b1 * a2; float d = (- a * x1 - b * y1 - c * z1); System.out.println("equation of plane is " + a + " x + " + b + " y + " + c + " z + " + d + " = 0."); } // Driver code public static void main(String[] args) { float x1 =-1; float y1 = 2; float z1 = 1; float x2 = 0; float y2 =-3; float z2 = 2; float x3 = 1; float y3 = 1; float z3 =-4; equation_plane(x1, y1, z1, x2, y2, z2, x3, y3, z3); } } // This code is contributed // by Amber_Saxena.
Python
# Python program to find equation of a plane # passing through given 3 points. # Function to find equation of plane. def equation_plane(x1, y1, z1, x2, y2, z2, x3, y3, z3): a1 = x2 - x1 b1 = y2 - y1 c1 = z2 - z1 a2 = x3 - x1 b2 = y3 - y1 c2 = z3 - z1 a = b1 * c2 - b2 * c1 b = a2 * c1 - a1 * c2 c = a1 * b2 - b1 * a2 d = (- a * x1 - b * y1 - c * z1) print "equation of plane is ", print a, "x +", print b, "y +", print c, "z +", print d, "= 0." # Driver Code x1 =-1 y1 = 2 z1 = 1 x2 = 0 y2 =-3 z2 = 2 x3 = 1 y3 = 1 z3 =-4 equation_plane(x1, y1, z1, x2, y2, z2, x3, y3, z3)
C#
// C# program to find equation // of a plane passing through // given 3 points. using System; class GFG { // Function to find equation of plane. static void equation_plane(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3) { float a1 = x2 - x1; float b1 = y2 - y1; float c1 = z2 - z1; float a2 = x3 - x1; float b2 = y3 - y1; float c2 = z3 - z1; float a = b1 * c2 - b2 * c1; float b = a2 * c1 - a1 * c2; float c = a1 * b2 - b1 * a2; float d = (- a * x1 - b * y1 - c * z1); Console.Write("equation of plane is " + a + "x + " + b + "y + " + c + "z + " + d + " = 0"); } // Driver code public static void Main() { float x1 =-1; float y1 = 2; float z1 = 1; float x2 = 0; float y2 =-3; float z2 = 2; float x3 = 1; float y3 = 1; float z3 =-4; equation_plane(x1, y1, z1, x2, y2, z2, x3, y3, z3); } } // This code is contributed // by ChitraNayal
PHP
<?php // PHP program to find equation // of a plane passing through // given 3 points. // Function to find equation of plane. function equation_plane($x1, $y1, $z1, $x2, $y2, $z2, $x3, $y3, $z3) { $a1 = $x2 - $x1; $b1 = $y2 - $y1; $c1 = $z2 - $z1; $a2 = $x3 - $x1; $b2 = $y3 - $y1; $c2 = $z3 - $z1; $a = $b1 * $c2 - $b2 * $c1; $b = $a2 * $c1 - $a1 * $c2; $c = $a1 * $b2 - $b1 * $a2; $d = (- $a * $x1 - $b * $y1 - $c * $z1); echo sprintf("equation of the plane is %.2fx" . " + %.2fy + %.2fz + %.2f = 0", $a, $b, $c, $d); } // Driver Code $x1 =-1; $y1 = 2; $z1 = 1; $x2 = 0; $y2 =-3; $z2 = 2; $x3 = 1; $y3 = 1; $z3 =-4; equation_plane($x1, $y1, $z1, $x2, $y2, $z2, $x3, $y3, $z3); // This code is contributed // by Amber_Saxena. ?>
Javascript
<script> // javascript program to find equation // of a plane passing through // given 3 points. // Function to find equation of plane. function equation_plane(x1 , y1 , z1 , x2 , y2 , z2 , x3 , y3, z3) { var a1 = x2 - x1; var b1 = y2 - y1; var c1 = z2 - z1; var a2 = x3 - x1; var b2 = y3 - y1; var c2 = z3 - z1; var a = b1 * c2 - b2 * c1; var b = a2 * c1 - a1 * c2; var c = a1 * b2 - b1 * a2; var d = (-a * x1 - b * y1 - c * z1); document.write("equation of plane is " + a + " x + " + b + " y + " + c + " z + " + d + " = 0."); } // Driver code var x1 = -1; var y1 = 2; var z1 = 1; var x2 = 0; var y2 = -3; var z2 = 2; var x3 = 1; var y3 = 1; var z3 = -4; equation_plane(x1, y1, z1, x2, y2, z2, x3, y3, z3); // This code is contributed by Rajput-Ji </script>
equation of plane is 26 x + 7 y + 9 z + 3 = 0.
Complejidad de Tiempo : O(1)
Espacio Auxiliar : O(1)
Publicación traducida automáticamente
Artículo escrito por anamika9988 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA