parallelogramarea.py

Created by matt-numworks

Created on September 30, 2024

405 Bytes

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

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.