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

guillaume laforge guillaume.laforge.3d at gmail.com
Tue Oct 30 16:50:55 EDT 2007


>(BTW, people should check out XSI's maths routines/objects for an example
>of a really well structured (and documented) system.)

Hi Andy :-)

Take a look at vops. It will be much more easy than a loonnng expression and
much more easy than using the XSI sdk ;-).
And if you don't find the node for your needs you can create your own
operator in VEX. I find VEX language is much more intuitive and fast to
write than the XSI Math object for example.

1/2

Guillaume Laforge | La Maison



On 10/30/07, Andy Nicholas <andy at andynicholas.com> wrote:
>
> Haha! Fantastic. Thanks so much for taking the time to type all that out.
> That's really cleared a lot of things up for me.
>
> So I take it from the last bit you wrote, you could also do something like
> this?:
>
> vector v = vector4(<expr>,<expr>,<expr>,<expr>);
>
> in which case, that solves the question about using the quattomatrix()
> function. I'll try it out.
>
> But is it me, or is this whole stripmatrix thing a little obtuse! It'd be
> great if they could just add direct member access like they already do for
> vectors. I've not starting using H9 yet, so maybe Python supports it.
>
> (BTW, people should check out XSI's maths routines/objects for an example
> of a really well structured (and documented) system.)
>
> Thanks again for your help Mario :-)
>
> All the best,
>
> Andy
>
>
> > On October 30, 2007 10:38 am, Andy Nicholas wrote:
> >
> >> i.e. this syntax (a trivial example):
> >>
> >> {
> >>    float a = ch("sparevar_a");
> >>    float b = ch("sparevar_b");
> >>    return a*b;
> >> }
> >
> > OK. That's the "expression language" -- part of "hscript", now replaced
> > (or
> > "superceded", I guess is a better term) with Python.
> >
> > Here's one way to extract elements or rows from a matrix using the
> > expression
> > language (either in-line like you're using it, or in a standalone custom
> > expression function):
> >
> > Extracting the translation 3-vector
> > {
> > string m = stripmatrix(optransform("/obj/ground"));
> > vector T = vector3(arg(m,12),arg(m,13),arg(m,14));
> > return T;
> > }
> >
> > A single element from the translation (x in this case)
> > {
> > string m = stripmatrix(optransform("/obj/ground"));
> > vector T = vector3(arg(m,12),arg(m,13),arg(m,14));
> > return T[0];
> > }
> >
> > Arbitrary element extraction:
> > {
> > string m = stripmatrix(optransform("/obj/ground"));
> > float m11 = arg(m,0);
> > float m12 = arg(m,1);
> > float m13 = arg(m,2);
> > float m14 = arg(m,3);
> > float m21 = arg(m,4);
> > float m22 = arg(m,5);
> > float m23 = arg(m,6);
> > float m24 = arg(m,7);
> > float m31 = arg(m,8);
> > float m32 = arg(m,9);
> > float m33 = arg(m,10);
> > float m34 = arg(m,11);
> > float m41 = arg(m,12);
> > float m42 = arg(m,13);
> > float m43 = arg(m,14);
> > float m44 = arg(m,15);
> > return m41;
> > }
> >
> > And so on. Basically: stripmatrix() converts the usual bracketed syntax
> > into a
> > space-separated list of components that the arg() function can then
> > extract
> > elements from.
> >
> >>
> >>
> >> 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?
> >
> > Expressions are used inside parameters to calculate some value. The list
> > of
> > functions that can be used in these expressions is given by typing
> > "exhelp"
> > in the textport. The hscript commands are used to manipulate your
> houdini
> > session via text commands, and the commands available are given when you
> > type
> > "help" in the textport.
> >
> >>
> >> >>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+"]");
> >
> > vector v = vector3(<expr>,<expr>,<expr>);
> >
> >
> > HTH. Cheers!
> >
> > --
> > ......................................................................
> > 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
>



More information about the Sidefx-houdini-list mailing list