[Sidefx-houdini-list] Expression syntax for matrices and vectors

Andy Nicholas andy at andynicholas.com
Tue Oct 30 11:38:54 EDT 2007


Hi Mario,

I'm looking for a syntax that'll work as an expression. I just found out
recently that it's possible to use multiple lines in an expression (by
using the Alt+E editor), so I've been trying to do slightly more
complicated stuff in them.

i.e. this syntax (a trivial example):

{
   float a = ch("sparevar_a");
   float b = ch("sparevar_b");
   return a*b;
}


Actually, you've just uncovered a bigger confusion for me here. What are
expressions? Are they supposed to be HScript? If so, what's the
difference?


>>so not clear what you mean.

Yes, you're right, I meant to type Matrix and Vector as lowercase. But
I've just figured that the only way (that I've found as yet) to create a
vector is to do this:

vector v = vector("["+unitz_x+","+unitz_y+","+unitz_z+"]");

not nice, but does the trick. It's a shame one can't pass a vector as a
literal, i.e.:

vector v = [unitz_x, unitz_y, unitz_z];

or even, the more usual C/C++ way

vector v(unitz_x, unitz_y, unitz_z);


BTW, I'd still love to know how to extract an element from a matrix. Let
me know if you have any ideas.

Another issue that I've come across is with regards to the quattomatrix()
command. It expects a Vector to be passed to it, and yet according to the
documentation, Vectors in expressions only consist of 3 elements, but a
quaternion is usually made up of 4. So how do you use this function?!!

Thanks for any confusion you can help to clear up :)

All the best,

Andy




> On October 30, 2007 09:04 am, Andy Nicholas wrote:
>> Matrix m = optransform("/obj/geom");
>> float unitz_x = m[8];
>> float unitz_y = m[9];
>> float unitz_z = m[10];
>> Vector v = {unitz_x, unitz_y, unitz_z};
>
> Is that meant to be hscript, or VEX?
> It's neither as written, but the optransform() function exists in both, as
> do
> the float, vector, and matrix types (all lowercase), so not clear what you
> mean.
>
> --
> ......................................................................
> Mario Marengo                                  mailto:mario at axyzfx.com
> AXYZ ANIMATION                                 http://www.axyzfx.com
> ......................................................................
>





More information about the Sidefx-houdini-list mailing list