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

Andrew D Lyons tstexture at gmail.com
Tue Oct 30 11:56:11 EDT 2007


Andy,

There are a few ways to write expressions in Houdini:

traditionally:
-----------------
hscript
expression language
custom expression language

then later
----------------
vex

and now in H9
-----------------------
python

In addition some of the OPmenu and io files have syntax variants.

What you are writing is a local custom expression function. These are
pretty handy for many things, (traditionally as globals), but aren't
as fast as vex for vector and matrix operations. Personally I'd drop
down a VOPsop and wire up what you are trying to do as a VOP.

Cheers



On 30/10/2007, Andy Nicholas <andy at andynicholas.com> wrote:
> 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
> > ......................................................................
> >
>
>
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>


-- 
=======================================
Andrew D Lyons | Digital Artist | http://www.tstex.com
=======================================



More information about the Sidefx-houdini-list mailing list