Adam Ferestad Posted October 4, 2014 Share Posted October 4, 2014 (edited) I am looking for a way to type a math expression into a string parameter, then evaluate it in the function. Specifically I am working on writing a Monte Carlo numerical integrator for a project I am doing that needs some integrals, but I am wanting to be able to use it for any expression. I want to be able to pass it the expression and bounds to evaluate, but I am unsure of how to actually make it evaluate the string as anything but. The old chrsraw() expression function did what I needed it to on an old project, but I am aiming to do this purely with VEX. This will eventually turn into a random variable node with more control over the distributions, but I need the gamma function for several of them, which requires an integral calculation, as do several others. As a side note, I got the Monte Carlo working for the gamma function, but it just couldn't get an accurate number in a good enough time, but I was able to get a rectangular rule that gets close enough. Edited October 4, 2014 by Adam Ferestad Quote Link to comment Share on other sites More sharing options...
edward Posted October 5, 2014 Share Posted October 5, 2014 Evaluate it in what function where? Quote Link to comment Share on other sites More sharing options...
Adam Ferestad Posted October 5, 2014 Author Share Posted October 5, 2014 (edited) Something like this: sop something(string expression, {variables}) { addattribute("result",evaluate(expression)) } obviously this is grossly oversimplified, but I want to have a parameter on my UI in the parameters pane that accepts me typing in something like pow(x,x)-3*x-2 and then actually processes it in the code. the end goal for this thread is that I can pass a math expression to a function call and have the function execute the expression with given variables. Edited October 5, 2014 by Adam Ferestad Quote Link to comment Share on other sites More sharing options...
edward Posted October 6, 2014 Share Posted October 6, 2014 Isn't that the same thing as what the new wrangler nodes do with the Snippet VOP? Quote Link to comment Share on other sites More sharing options...
Adam Ferestad Posted October 7, 2014 Author Share Posted October 7, 2014 I am unfamiliar with those nodes. Could you point me in the direction of the documentation for them to see if I can apply them. I am really trying to do it in VEX, but if I have to do it using VOPs I suppose I can. Quote Link to comment Share on other sites More sharing options...
Guest tar Posted October 7, 2014 Share Posted October 7, 2014 Hey Adam - the Wrangle nodes are Vex - The online docs have it all. e.g. http://www.sidefx.com/docs/houdini13.0/nodes/sop/pointwrangle Quote Link to comment Share on other sites More sharing options...
mitul Posted October 27, 2014 Share Posted October 27, 2014 (edited) if you are using python eg. you want to set expression in tx of point node my_node = hou.node('/obj/geo1/point1') my_tx = my_node.parm('tx') my_tx.deleteAllKeyframes() # to delete any existing expression my_tx.setExpression ('$TX + rand($PT)') Edited October 27, 2014 by mitul Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.