aligning one vector to another vector (python)

38 views
Skip to first unread message

e955...@gmail.com

unread,
Oct 20, 2014, 3:52:08 PM10/20/14
to python_in...@googlegroups.com
Hello all,

i have a vector that i am using to fire rays around a particular axis. But i need to be able to adjust the rotation of this vector axis with another vector.

Does anyone know the smartest way to orient a vector, based on the orientation of another vector?

im guessing with a rotation matrix. But do i need to convert the orientation vector to degrees first.

any advice would be cool,
thanks,
Sam

Michael Boon

unread,
Nov 2, 2014, 7:42:23 PM11/2/14
to python_in...@googlegroups.com, e955...@gmail.com
I'm not really clear on what you're trying to do, but Pymel's Vector class has a method that might help: Vector.rotateBy(axis, angle)

Alternatively, you can definitely use a matrix. Maybe look at TransformationMatrix.setToRotationAxis

Or maybe you already figured it out :)

Michael Boon

unread,
Nov 2, 2014, 7:55:24 PM11/2/14
to python_in...@googlegroups.com, e955...@gmail.com
Just occurred to me that you might simply want to make vector A point in the same direction as vector B.

OK so sticking with Pymel. A and B are Pymel Vectors:
A = B.normal() * A.length()

Reply all
Reply to author
Forward
0 new messages