Find the area of a parallelogram using three arrays where p is between q and r. The script first calculates PQ and PR, then uses those values to find the cross product and ultimately the area of the parallelogram.
import numpy as np p = [1, 0, 0] q = [0, 1, 0] r = [0, 0, 1] def a(p, q, r): # Calculate vectors PQ and PR PQ = np.array(q) - np.array(p) PR = np.array(r) - np.array(p) # Calculate the cross product of PQ and PR cross_product = np.cross(PQ, PR) # The area is the magnitude of the cross product area = np.sqrt(np.sum(cross_product**2)) return area