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

Andy Nicholas andy at andynicholas.com
Tue Oct 30 12:09:58 EDT 2007


Hi Andrew,

My god, no wonder I've been getting confused! Thanks ever so much for the
summary.It's really good to have a better overall awareness of the
structure.

It's a real shame that the documentation barely reflects what you
outlined. The documentation (or lack of) is one of my biggest frustrations
at the moment.

Yes, I've done a bit of VEX VopSop'ing. It's a great tool; really
flexible. I just find that sometimes I only need to do a couple of simple
things with vectors and matrices and don't need to actually do any
modifications to points themselves, since the Sop is doing most of that
already.

Essentially I don't want to have to reverse engineer an entire section of
nodes just for the sake of avoiding a bit of syntax! But I am finding that
I'm having to do exactly that (or even nastier workarounds) just because
there's some basic documentation missing.

Anyway, rant over :-) Again, if anyone knows how to access a matrix
element, please let me know as you'll be saving me a lot of work!

Thanks again

Andy







> 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