Function arctan(x) in expression

Hello everyone,

Does anyone have experience with calculating the arc tangent → arctan(x) for calculating an angle?

Because the function doesn’t seem to exist in the expression editor, do you have any good alternatives?

Many thanks in advance.

Kind regards
Paul

1 Like

Hey @pwied -

This isn’t possible yet in the expression editor but I just wrote a feature request for this. In the meantime, I did create a custom widget that does exactly this:

It takes inputs:

  1. X
  2. The operation you want to do: sin,cos,tan,asin,acos,atan

Whenever the value of X changes, the widget will recalculate the value of the result variable.

In the example video above I show the widget itself visible on the app step, but it can be outside of the viewable area of the app and it will still execute.

customWidget-Trig Operations (1).json (3.0 KB)

Hope this helps,
Pete

Hi @Pete_Hartnett,

great widget.

I would consider, to also start calculating, when the opration changes (and x has a valid value).
That ensures, that you will never have a situation, where you can see a result, that does not fit to your inputs (changing operation after first result was delivered would lead to an unvalid combination on screen).
You could also clear the x value and the result after changing the operation but, I think thts less unser friendly.

Do you get my point?
What do you think?

Hi @Pete_Hartnett

Thank you very much for your support.

I think there was a small error in the javascript in the calculation of the atan: “res = Math.cos(x)” instead of “res = Math.atan(x)”.

Here is my further development of Pete’s custom widget: Changed calculation of atan and calculation of the result in degrees (instead of rad):

customWidget-Trig Operations.json (3.0 KB)

Many greetings
Paul

Good catch @pwied and @thorsten.langner -

Attached is a V2 of this app that fixes. It now runs the logic on changes to Operation or X and the atan issue is resolved.

customWidget-Trig Operations (1).json (3.0 KB)

I also updated the original post with this version

Pete

Please let me note that my colleague is also waiting for this to come! (He needs arccos)

Custom function editor could be an interesting feature. As could the use of the Jsonata library.

1 Like

Hey @Pete_Hartnett,

Do you already have an update for us for further mathematical functions within the expression editor?

We now have another customer who is also missing the sinus hyperbolic.

Already available:

sin()
cos()
tan()

What we are missing:

asin()
acos()
atan()

sinh()
cosh()
tanh()

We have added the functions to the custom widget for time being, but it would be useful for apps that support workers with these complicated calculations if they were also available in the expression editor.

Thanks!
Jeremy

Hi @Jeremy,

Thanks for the feedback here - I’m curious to better understand the use case for additional functions.

Sincerely,

Jake

FWIW this can be solved using any postgres database connection. Tulip hosts and provides a random one out of the box which is a little bit suspect but gets the job done. We continue to see a need for more natural ways to use javascript or postgres for custom, global expressions.

3 Likes

Hi @jakerigos ,

In general, these are basic mathematical functions for the industry.

For this special use case:
They align spindle towers during assembly.
These are mounted on a 3-point support and underlaid with washers.
We now want to calculate, what washer height needs to be placed underneath to align the tower parallel to a guide.
The required washer height is then displayed to the worker.

Regards
Jeremy

1 Like

Understood - thanks for the context @Jeremy!