 • # Advanced math expressions, e.g. Math.cos()

Hello everyone!

I’m trying to measure a volume of water in my water tank using ultrasonic sensor. The sensor gives me water level in the tank but as the tank is cylindrical I need to re-calculate this to the water volume in order to know how much water is in there. For that, I need to use the cos() function. I’ve tried to use an expression with cos() or Math.cos() but without success.

Would anyone have an idea how to tweak Pimatic to work with cos() function?  • @Jan-Hicl I am just wondering. Isn’t it `Math.acos()` what you need for the given calc?

``Volume = L * (Math.pow(R, 2) * Math.acos((R - D)/ R) - (R - D) * Math.sqrt(2 * R * D - Math.pow(D, 2)))``

"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law

• @mwittig yep, you’re right! I supposed if there is a way for cos(), there’s gonna be ways for acos() as well. Anyway, do you think there is a way I could get this formula working?

Thanks

• @Jan-Hicl I’ll add sqrt, cos, acos with the next release and keep you posted. The pimatic expression for given variables \$L, \$D, and \$R will looks as follows:

``\$L * (pow(\$R) * acos((\$R - \$D) / \$R) - (\$R - \$D) * sqrt(2 * \$R * \$D - pow(\$D)))``

"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law

• Wow, thanks a lot! Really appreciate that and all the other work you’ve done on Pimatic! I’ve been using it for last 2 year and I love it more and more T

Thank you!

• @Jan-Hicl Thanks, for the positive feedback! I am glad you like pimatic. If you have further suggestions please do not hesitate to post them. Note, however, the base of active developers on pimatic is relatively small, and thus, we can only pick the low hanging fruits most of the time.

pimatic@0.9.41 including the required functions has bee released

"It always takes longer than you expect, even when you take into account Hofstadter's Law.", Hofstadter's Law

Posts 6Views 2019

Looks like your connection to pimatic forum was lost, please wait while we try to reconnect.