1
$\begingroup$

I'd like to get the cosine of all elements in a Vector in Blender's python. Should I just use numpy for this?

Edit: I was tired when I wrote this and kind of mis-posed the question. What I actually meant was that I have a list of all the blender Vectors containing x, y, and z, and I want to do things like calculate the cosine of each x. But this answer does a good job of addressing the question that I actually wrote and it put me on the road to solving the problem I was trying to solve so I'm accepting it.

$\endgroup$
1
  • 1
    $\begingroup$ not quite sure of the vector class in blender. If it were a list you could use the map function $\endgroup$ Apr 12 '16 at 6:59
4
$\begingroup$

You could use the map list functionality

new_vector = Vector(map(lambda x: sin(x), list(vector_variable)))

maybe even better

new_vector = Vector(sin(x) for x in vector_variable)

see here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.