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

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,

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

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


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