How to do rotation in programming by using vex language?

   19639   4   5
User Avatar
Member
1 posts
Joined: 5月 2014
Offline
Hi, I'm a beginner of Houdini.
Can anyone teach me how to rotation a square or circle by using vex code?
Thank you very much!
User Avatar
Member
4526 posts
Joined: 2月 2012
Offline
Hi,

You can use this to rotate an object by 20 degrees in Y:

matrix3 m = ident ( );
rotate ( m, radians ( 20 ), { 0, 1, 0 } );
@P *= m;
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
8587 posts
Joined: 7月 2007
Offline
you can as well use quaternions to do the same thing

@P = qrotate( quaternion( {0,20,0}, 0 ), @P );

if you are already familiar with matrices and quaternions it may be helpful to browse the docs to get see all the functions that VEX has to offet for manipulating them (or to read more about above mentioned ones)
http://www.sidefx.com/docs/houdini13.0/vex/functions/ [sidefx.com]
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
1391 posts
Joined: 12月 2010
Offline
Also we have maketransform function for doing all transformation (Translate , Rotate , Scale) on the points.

maketransform(0,0,{ TX, TY, TZ },{ RX, RY, RZ},{ SX, SY, SZ },{ CEX, CEY, CEZ });

Example : ( Rotate points 45 degree along Y axis )


v@Temp = @P * maketransform(0,0,{ 0, 0, 0 },{ 0, 45, 0 },{ 1, 1, 1 },{ 0, 0, 0 });
@P = @Temp;
https://www.youtube.com/c/sadjadrabiee [www.youtube.com]
Rabiee.Sadjad@Gmail.Com
User Avatar
Member
12 posts
Joined: 10月 2014
Offline
And there is something handy at times - optransform() to fetch transform matrix from any obj at scene level.

matrix M = optransform(“/obj/yourTransformedObj”) ;
@P *= M ;


Cheers !
- GM
  • Quick Links