Find area of triangle if two vectors of two adjacent sides are given | Python code to calculate area of triangle if vectors of 2 adjacent sides are given ; function to calculate area of triangle ; driver code
import math NEW_LINE def area ( x1 , y1 , z1 , x2 , y2 , z2 ) : NEW_LINE INDENT area = math . sqrt ( ( y1 * z2 - y2 * z1 ) ** 2 + ( x1 * z2 - x2 * z1 ) ** 2 + ( x1 * y2 - x2 * y1 ) ** 2 ) NEW_LINE area = area / 2 NEW_LINE return area NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT x1 = - 2 NEW_LINE y1 = 0 NEW_LINE z1 = - 5 NEW_LINE x2 = 1 NEW_LINE y2 = - 2 NEW_LINE z2 = - 1 NEW_LINE a = area ( x1 , y1 , z1 , x2 , y2 , z2 ) NEW_LINE print ( " Area ▁ = ▁ " , a ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT