Home > database >  How can I store multiple numpy vectors conveniently?
How can I store multiple numpy vectors conveniently?

Time:12-14

My car has 4 wheels and I want to caculate the weight in Newtons on each of the wheels given a mass and center of gravity. I want to store the vectors from origin to each of the 4 wheels conveniently so that I can use the cross product of numpy. Currently I have this:

location_wheel = [np.array([]), np.array([]), np.array([]), np.array([])]

Where the first array would be the front left wheel, second one the front right one etc. I feel like there's a better or more convenient way to do this. Got any suggestions?

I also thought of making 4 separate variables, though that made even less sense to me.

CodePudding user response:

You could also try to have a 2d np array like this.

arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])

or

arr = np.ndarray(shape=(x,y), dtype=float)
  • Related