Jump to content


Multiply vector3 and matrix3 in Python?


  • Please log in to reply
6 replies to this topic

#1 magneto

magneto

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,291 posts
  • Joined: 04-October 11
  • Location:Canada
  • Name:Ryan K

Posted 09 June 2012 - 09:39 PM

It seems like the help file says only vector4 and matrix4 multiplication is possible.

Is this true? How can I multiply a vector3 with matrix3?


Thanks.

#2 rdg

rdg

    Houdini Master

  • Members
  • PipPipPipPip
  • 729 posts
  • Joined: 21-August 05
  • Location:weta
  • Name:Georg Duemlein

Posted 09 June 2012 - 10:54 PM

Quote

Note that you can construct a general transformation Matrix4 from a Matrix3 by writing hou.Matrix4(matrix3).

The Industrial Parametrization of the World
http://rdg.preset.de/

#3 magneto

magneto

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,291 posts
  • Joined: 04-October 11
  • Location:Canada
  • Name:Ryan K

Posted 10 June 2012 - 12:37 AM

Thanks, that's how I did but found it strange it wasn't supported by default.

#4 graham

graham

    Houdini Master

  • Moderator
  • 666 posts
  • Joined: 13-September 06
  • Location:Santa Monica, CA
  • Name:Graham Thompson

Posted 10 June 2012 - 07:16 AM

Not sure exactly what you are referring to, but if you look at the docs for the various classes you will see that a hou.Vector3 can be multiplied by a 3x3 or 4x4 matrix depending on what you are trying to do.

http://www.sidefx.co...Vector3#__mul__
http://www.sidefx.co...hom/hou/Matrix4
I write python and break things.

#5 magneto

magneto

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,291 posts
  • Joined: 04-October 11
  • Location:Canada
  • Name:Ryan K

Posted 11 June 2012 - 06:19 AM

Hi Graham, are you sure? Because when I did vector3 * matrix3x3, I got a compile error. Also in the help, the signature for the multiplication is:

__mul__(self, scalar_or_matrix4)

so either scalar or matrix4.

Please let me know if I can actually use a matrix3x3. When I try, it gives a compile error, which is what led me to the help file :)

#6 graham

graham

    Houdini Master

  • Moderator
  • 666 posts
  • Joined: 13-September 06
  • Location:Santa Monica, CA
  • Name:Graham Thompson

Posted 11 June 2012 - 07:00 AM

You can ignore my post because I'm an idiot and didn't pay enough attention to the docs while also thinking about the HDK.  This should be possible since Houdini stores its data in row-major format and you can multiply a UT_Vector3T by a UT_Matrix3T.  The issue is that hou.Vector3 merely has no __mul__ method that accepts a hou.Matrix3.  I've submitted an RFE for the missing functionality.  Georg is right in that you should convert to a Matrxi4 to do the multiplication.  Sorry for being dumb.
I write python and break things.

#7 magneto

magneto

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,291 posts
  • Joined: 04-October 11
  • Location:Canada
  • Name:Ryan K

Posted 11 June 2012 - 07:26 AM

Np man :) Thanks for submitting an RFE for this. Hopefully it will be added one day. AT least now there is a workaround.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users