Curious how to work with inverse trig?

Hello, I am trying to plot an inverse trig function using lilaq. However, there is an issue as lilaq gets confused with the interaction of angles and integers. See: lq.plot(relativedistancexvalue,relativedistancexvalue.map(x=>(1.3*calc.atan((2.5/x) +0.15))+10)). The issue is that lilaq doesn’t want to add “10” to the existing expression because the result from arctan is an angle. Is there a workaround? For example, is there a way to classify the 10 as 10 degrees?

Please format code as such, using fenced code block, see How to post in the Questions category.

If you mean 10 degrees, you should be able to write 10deg. See Angle Type – Typst Documentation.

I’m guessing the code you need is:

lq.plot(relativedistancexvalue,relativedistancexvalue.map(x=>(1.3*calc.atan((2.5/x) +0.15))+10deg))

So with this: lq.plot(relativedistancexvalue, relativedistancexvalue.map(x=>((1.3 * calc.atan((2.5 / x) + 0.15)) + 10deg) typst has a compile error: " Expected float, found angle". I may just try and plot the coordinates from a .csv.

For those that come across this post. Something that worked for me was to divide the result of the inverse trig by /1deg. Then, add the integer in front of the trig expression. Not sure why that worked but it did!

1 Like

According to the documentation for arctan ( Calculation Functions – Arctan), the return value is an angle.

Angles have a method for retrieving the value as a float in deg or rad, check out Angle Type − Conversion to Degree. Just call arctan(x).deg(). But dividing by 1deg is just as valid.

2 Likes