Eigen Vector in Maya with Numpy ?

210 views
Skip to first unread message

maurizio1974

unread,
Mar 21, 2010, 7:05:33 PM3/21/10
to python_inside_maya
Hi

When I was at ILM there was a cool tool that would calculate the
orientation of an object based on the volume
thanks to the eigenvector.
There they were using some old module called Linear Algebra to get the
eigenvector result from the arrays
of the object, but I know that Numpy has integrated the Linear Algebra
Module so I guess that is the same.

I haven't been able to find a good way to just get an object parsing
on the matrices of the individual vertex and then
feed a 4x4 matrix to Numpy so that would give me a matrix that applied
to a Locator would result to the right orientation of the object even
if the original pivot is completely in a different position like when
we freeze the transform on a rotated object in space.

Anyone got a clue of a reasonably simple way to do that ?

Thank you in advance.

Ozgur Yılmaz

unread,
Mar 24, 2010, 8:04:46 AM3/24/10
to python_in...@googlegroups.com
so you want to stick a locator on to an objects vertex ?

E.Ozgur Yilmaz
Lead Technical Director
www.ozgurfx.com



--
http://groups.google.com/group/python_inside_maya

To unsubscribe from this group, send email to python_inside_maya+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

Beau Garcia

unread,
Mar 24, 2010, 6:35:43 PM3/24/10
to python_in...@googlegroups.com
Im not 100% sure this is what your asking,
But If you want to work out the orientation of a object based on the actual mesh information,  rather than its transform.
I guess you could specify 3 vertex ID's which will allow you to calculate the cross products and derive a orientation that way.
The vertex ID's would have to remain the same for it to work though.

Beau

maurizio1974

unread,
Mar 24, 2010, 7:08:58 PM3/24/10
to python_inside_maya
No Yilmaz ,I don't want to stick a Locator on a vertex, this is what I
am trying to do.
What Eigen Vectors can do is to get the orientation of a volume .
SO basically I could get the polygon orientation of the whole object
based on the volume that will need to broken down
to matrices of the vertex that make it to be fed to Numpy .
Assuming that you have a cube in space and you rotate it to an
arbitrary rotation value.
At this point if you freeze the transformation and center the pivot
you will have the pivot point
oriented to the world and not the actual roattion of the cube.
Eigen Vectors and Eigen values can give yo that rotation to be fed in
to the transform matrix and regain that orientation based on the
object and not the pivot point.
This is a case but many times you can get objects form different
places or different conversion application and need to get a decent
pivot to manipulate the object.

I hope my explanation was clear enough.

Thank you

On Mar 24, 12:04 pm, Ozgur Yılmaz <eoyil...@gmail.com> wrote:
> so you want to stick a locator on to an objects vertex ?
>
> E.Ozgur Yilmaz
> Lead Technical Directorwww.ozgurfx.com
>

Chad Dombrova

unread,
Mar 24, 2010, 10:47:59 PM3/24/10
to python_in...@googlegroups.com
i understand what you're saying and i would be very interested in this as well. what are the building blocks required? break it down for me: what's the name of the function in numpy? what are it's inputs and outputs?

numpy.somefunc( someval ) -> eigen_vector ??

once this is clear we can start figuring out how to gather your required inputs.

-chad

> To unsubscribe from this group, send email to python_inside_maya+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

Matthew Chapman

unread,
Mar 24, 2010, 11:38:43 PM3/24/10
to python_in...@googlegroups.com
Hey Maurizio,

I believe you are looking for the code defining an object oriented bounding box. This uses the eigen vectors of a covariance matrix. Alas I cannot provide any sample code.... but this site has been kind enough to give out c code. A port of this math lib would be a great addition to pymel.

http://www.geometrictools.com/LibFoundation/Containment/Containment.html

Good to hear from you Marurizio don't be a stranger to SF.

Matt



--

Chad Dombrova

unread,
Mar 25, 2010, 1:39:27 AM3/25/10
to python_in...@googlegroups.com

> A port of this math lib would be a great addition to pymel.

i agree!

if anyone pulls this off, please contribute back.

-chad


maurizio1974

unread,
Mar 25, 2010, 5:18:11 AM3/25/10
to python_inside_maya
Kick ass Matt

great to hear form you.

I believe that the linear Algebra Class in Numpy can get that done as
long as you feed in the right matrix.
I guess I don;t know how to get a covariance matrix from a mesh.
It think it is something like gettinng the centroid of an object.
Those libraries are great is there an easy way to call them from
Python that you know ?

Ciao Bro

On Mar 25, 3:38 am, Matthew Chapman <chapman...@gmail.com> wrote:
> Hey Maurizio,
>
> I believe you are looking for the code defining an object oriented bounding
> box. This uses the eigen vectors of a covariance matrix. Alas I cannot
> provide any sample code.... but this site has been kind enough to give out c
> code. A port of this math lib would be a great addition to pymel.
>
> http://www.geometrictools.com/LibFoundation/Containment/Containment.html
>
> Good to hear from you Marurizio don't be a stranger to SF.
>
> Matt
>

maurizio1974

unread,
Mar 25, 2010, 5:23:38 AM3/25/10
to python_inside_maya
Hey Chad

the call form numpy is

numpy.linalg.eigh

so basically the clas linalg as a definition to calculate the
eigenvectors if you pass
a covariance matrix.

Not sure how to pass a covariance matrix though.

depends wheather you need to find the

Reply all
Reply to author
Forward
0 new messages