Taking multiple point (X Y Z) inputs from user and storing them in separate arrays in Python

Viewed 33

I'm trying to perform matrix transformations using numpy arrays so I need the points saved in arrays (arr1-[[x1],[y1],[z1]]), (arr2-[[x2],[y2],[z2]]) in column form(shape-3,1)

How do i go about taking multiple inputs and storing them ?

Should I use a 3d array to store all points ? How do I proceed with the calculations in this case..

Any material regarding this will also be helpful

Thanks

1 Answers

You can .append() everything to an normal list in Python. Actually even if you put groups of three values in the list it is 2 Dimensional. Something like this should work:

pointsFromUser = []
while <how long to collect>:
    pointFromUser = <Get Pointfrom User>
    pointsFromUser.append(pointFromUser)

If you have to use numpy you can adapt it like this:

import numpy as np

pointsFromUser = np.array([])
while <how long to collect>:
    pointFromUser = <Get Pointfrom User as array>
    pointsFromUser = np.append(pointsFromUser, [pointFromUser], axis=0)
Related