Determine position of two points with respect to a 3D plane | C ++ program for the above approach ; Function to check position of two points with respect to a plane in 3D ; Put coordinates in plane equation ; If both values have same sign ; If both values have different sign ; If both values are zero ; If either of the two values is zero ; Driver Code ; Given Input ; Coordinates of points ; Function Call
#include <iostream> NEW_LINE using namespace std ; void check_position ( int a , int b , int c , int d , int x1 , int y1 , int z1 , int x2 , int y2 , int z2 ) { int value_1 = a * x1 + b * y1 + c * z1 + d ; int value_2 = a * x2 + b * y2 + c * z2 + d ; if ( ( value_1 > 0 && value_2 > 0 ) || ( value_1 < 0 && value_2 < 0 ) ) cout << " On ▁ same ▁ side " ; if ( ( value_1 > 0 && value_2 < 0 ) || ( value_1 < 0 && value_2 > 0 ) ) cout << " On ▁ different ▁ sides " ; if ( value_1 == 0 && value_2 == 0 ) cout << " Both ▁ on ▁ the ▁ plane " ; if ( value_1 == 0 && value_2 != 0 ) cout << " Point ▁ 1 ▁ on ▁ the ▁ plane " ; if ( value_1 != 0 && value_2 == 0 ) cout << " Point ▁ 2 ▁ on ▁ the ▁ plane " ; } int main ( ) { int a = 1 , b = 2 , c = 3 , d = 4 ; int x1 = -2 , y1 = -2 , z1 = 1 ; int x2 = -4 , y2 = 11 , z2 = -1 ; check_position ( a , b , c , d , x1 , y1 , z1 , x2 , y2 , z2 ) ; return 0 ; }