Convert List into vector???

Hi there,

I am trying to convert a list of lists (see example below) into vectors so that I may calculate an object rotation angle by referencing to (1,0,0), (0,1,0), and (0,0,1)


list = [(1,2,3),(2,3,4),(3,4,5)]

I would like to convert it to vectors (see below) but I am having issues. I would appreciate any help :slight_smile:


list = [Vector([1,2,3]),Vector([2,3,4]),Vector([3,4,5])]

Thanks!
-ejang

Get rid of the square brackets in example 2, so it’s Vector (x, y, z) not Vector ([x, y, z]). As is, it’s trying to make a one-item vector, with the list as the one item.

Also in your first example, ‘list’ is a list of tuples since it has regular parentheses around the items. That shouldn’t be a problem, but generally tuples are less useful than lists, just a convenience.


values = [[1, 2, 3], [4, 5, 6], [9, 8, 2]] # Square brackets
 
vec = Vector (values[0]) # 'vec' should now be Vector (1, 2, 3), (or 1.0, 2.0, 3.0)
 
vecs = [Vector (val) for val in values] # 'vecs' should now be a list of all the vectors

Dave Heinemann, 4th year noob