Do Math syntax & functions?

I’m experimenting with ‘Do Math’ and sometimes run into what I think are syntax errors. Is there any way I can be certain of what kind of error I’m making? For now, I’m assuming that the text field reverting to ‘$VAL’ means there’s an error, and that it’s most probably a syntax error. But is my assumption correct?

Also, I’m using sliders for debugging purposes, so mathematical errors would result in their received values being off. It works, but maybe there are better ways to visualise or log output from Do Math?

Re: syntax errors, is the expected syntax fully described anywhere? I’m assuming standard mathematical notation, but is it also possible to do some scripting? The Wiki https://github.com/davedelong/DDMathParser/wiki/Usage has variables and Evaluators, but those are for code making use of DDMathParser, no? (i.e. VDMX code for ‘Do Math’, not for end users).

TL;DR, I’m assuming these lists of Operators and Functions, standard mathematical notation, no scripting or customisation. Is this correct?

Thanks!

Ah, the dark art of “Do Math” :slight_smile: David touched on this in a blog post a few years back but it remains pretty undocumented… (1.0+sin($VAL*2*PI))/2.0 … 4.0!pow($VAL-0.5,2)

2 Likes

Cheers mate! Good to know that it’s undocumented too. No use to search for what isn’t.

Hey all,

I just added some quick notes to the VDMX docs that adds some basic information on usage, definitely an oversight on our part!

I’ll also mention that while the existing ‘do math’ can be extremely useful in some odd edge cases, we know it is fairly limited in a lot of ways, and we’re currently working on a new feature that will hopefully be a lot more powerful for folks who need to do a bit of custom math expression / logic control on numbers being passed around in VDMX. Definitely will have some nice documentation to go along with that, and in the meantime we’d love to hear some of the real world use cases people have for this kind of situation, and what sorts of stuff you’d like to see expanded on in this direction.

5 Likes

Thanks for putting it in the official manual, appreciated!

However, I’m not sure about the link to ‘Usage’. It directs to usage of DDMatchParser when building an app using it, so it’s not for users.

To me, Do Math? is really nice for doing some quick & simple arithmetic. When expressions get complex, it’s hard to know what went wrong because there’s no error message.

That said though, when I’m that complex territory, it’s quite likely that I’m overthinking some detail, and would be on my way into a rabbit hole – Error messages won’t help if I’m way over my head math-wise.

So error messages would be nice for at least knowing if the expression parses. Finding mathematical errors too? Not so sure. In those cases, my vote would go to adding to Num Fx instead, much easier to use and to understand anyhow.

Hi David, looking forward to the new Do Math features. I think for me the Do Math functions works well for repeatable transforms when working with animation. It’s quicker to cut and paste a function instead of configuring a new wave in a LFO plugin. But it’s a bit of a dark art and as I’m terrible at writing functions it can pretty haphazard. But saying that a lack of knowledge can create unusual movements which is good. Scaling a function always baffles me, you might create a nice movement but it’s clipped to say half the slider length. This was covered in a tutorial years ago but I’ve lost the reference and I think having a basic set of template functions to help users get started would be really valuable.

1 Like