Sep-22-2018, 08:30 PM
(This post was last modified: Sep-22-2018, 08:35 PM by ichabod801.)
Hello,
I was trying to solve an exercise where I needed to calculate the area of the box where I should input the coordinates of the specific box (Box1 or Box2) and then calculate the area.
This is my code so far:
I was trying to solve an exercise where I needed to calculate the area of the box where I should input the coordinates of the specific box (Box1 or Box2) and then calculate the area.
This is my code so far:
import numpy as np
def boxArea(boxCorners, area):
x = np.array([boxCorners])
if area == "Box1":
x = np.array([boxCorners])
A = ((x[1]-x[0])*(x[3]-x[2]))
elif area == "Box2":
A = ((x[1]-x[0])*(x[3]-x[2]))
return AThe problem is that I constantly get this error message: "IndexError: index 1 is out of bounds for axis 0 with size 1". I really do not understand what is the problem in this code. Hope that someone can help me.
