Find area of triangle if two vectors of two adjacent sides are given | C ++ program to calculate area of triangle if vectors of 2 adjacent sides are given ; function to calculate area of triangle ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; float area ( int x1 , int y1 , int z1 , int x2 , int y2 , int z2 ) { float area = sqrt ( pow ( ( y1 * z2 - y2 * z1 ) , 2 ) + pow ( ( x1 * z2 - x2 * z1 ) , 2 ) + pow ( ( x1 * y2 - x2 * y1 ) , 2 ) ) ; area = area / 2 ; return area ; } int main ( ) { int x1 = -2 ; int y1 = 0 ; int z1 = -5 ; int x2 = 1 ; int y2 = -2 ; int z2 = -1 ; float a = area ( x1 , y1 , z1 , x2 , y2 , z2 ) ; cout << " Area ▁ = ▁ " << a << endl ; return 0 ; }