Jump to content
You must now use your email address to sign in [click for more info] ×

1.7.0.3 Inverse trig functions appear to be invalid in Transform panel


Recommended Posts

There's another report regarding "sqrt(2)" not working, but "*sqrt(2)" working. That is, functions that result in a constant (e.g., 1.414) are not being processed, but functions used in an expression based on the image dimensions (H, W) do work.

-- Walt
Designer, Photo, and Publisher V1 and V2 at latest retail and beta releases
PC:
    Desktop:  Windows 11 Pro, version 23H2, 64GB memory, AMD Ryzen 9 5900 12-Core @ 3.00 GHz, NVIDIA GeForce RTX 3090 

    Laptop:  Windows 11 Pro, version 23H2, 32GB memory, Intel Core i7-10750H @ 2.60GHz, Intel UHD Graphics Comet Lake GT2 and NVIDIA GeForce RTX 3070 Laptop GPU.
iPad:  iPad Pro M1, 12.9": iPadOS 17.4.1, Apple Pencil 2, Magic Keyboard 
Mac:  2023 M2 MacBook Air 15", 16GB memory, macOS Sonoma 14.4.1

Link to comment
Share on other sites

  • Staff
On 12/1/2018 at 1:36 PM, >|< said:

According to the app Help, expressions support the inverse trig functions asin, acos and atan.

What topic of the help is that? The only ones listed in Expressions for Field Input are Sin, Cos and Tan.

Link to comment
Share on other sites

  • Staff

Thanks for that! It could be the asin/acos/atan are primarily designed for use in the Equations and Procedural Texture filters. I shall double check with development! :) 

 

EDIT: I have a feeling this could be the same as the issue Walt mentioned above so I've passed it on to development. Average(5,10) was also failing for me!

Link to comment
Share on other sites

  • Staff

This is because the functions listed above all output a pure number.  We don't then promote the pure number to a measurement.  What should the measurement be??  You can explicitly add a unit type to a result - if you put in "average(5,10) mm" you will get the answer 7.5mm.

"*sqrt(2)" works because it is multiplying the current value (which has units) by root 2.  The answer adopts the units of the current value - so this works.  It's the same as if you wrote "*2".

 

Also - trig functions that return an angle won't work in a field that requires a distance value.  So, for example, you can't use "atan2(h,w)" in the X field.  You would have to convert the value by using another trig function (such as cos).

 

There are a number of rules we have for how functions and operators adopt or change unit types.  I'll make sure these are in the documentation as soon as I can.

 

It is possible that I'll add back in the promotion of pure values to the current document unit type.  That won't work mid-expression though.  For example "average(w,2)" won't be allowed because w has units and 2 is pure. We used to allow promotion to unit type inside of function calls, but that had too much potential for confusion.

 

Results from simple operators (+ - * /) will allow promotion to current unit type.

 

A short list of how unit types are promoted:

 

*2, /2, +=2, -=2  -  Unit type taken from existing value.

x+2, x-2, 2+x, 2-x  -  Special case, 2 is promoted to the unit type of x, before addition or subtraction. Result is in unit type of 'x'.

x*2, 2*x, x/2  -  Unit type taken from type of 'x'.

x*y  -  Technically the unit type should be an area, but we just promote to the uni type of the left hand value.

x/y  -  Result is a pure number (technically a ratio, and has no unit type).  The result will not be automatically promoted to a unit type.

2/x  -  Not allowed, unless x is a pure value

 

Result from trig functions

sin, cos, tan  -  take an angle (assumed to be degrees unless you use deg or rad unit type), and outputs a pure number.

acos, asin, atan  -  the inputs must be pure values, the output is an angle.

atan2  -  the inputs must both be pure, or both a distance type.  The output is an angle.

 

Result from other functions

sqrt(2)  -  result is a pure number.

sqrt(x)  -  result adopts the unit type of 'x'.

sqrt(100mm)  -  result would be 10mm.

sqrt(100) mm  -  The result is explicitly promoted to mm, so the result is 10mm.

 

SerifLabs team - Affinity Developer
  • Software engineer  -  Photographer  -  Guitarist  -  Philosopher
  • iMac 27" Retina 5K (Late 2015), 4.0GHz i7, AMD Radeon R9 M395
  • MacBook (Early 2015), 1.3GHz Core M, Intel HD 5300
  • iPad Pro 10.5", 256GB
Link to comment
Share on other sites

  • Staff
On 12/1/2018 at 1:36 PM, >|< said:

AD 1.7.0.3

macOS 10.13.6

According to the app Help, expressions support the inverse trig functions asin, acos and atan.

The inclusion of an inverse trig function in a field of Transform panel results in no change to the previous value in the field.

For example, asin(0.5)*10 entered into the H field is not evaluated.

 

Just to add - your example "asin(0.5)*10" results in an angle value - the H field is a position/size field so only takes distance units for a result.

 

If you need to convert an angle to a scalar (pure number), you will need to divide it - for example, "asin(0.5)/1deg".

SerifLabs team - Affinity Developer
  • Software engineer  -  Photographer  -  Guitarist  -  Philosopher
  • iMac 27" Retina 5K (Late 2015), 4.0GHz i7, AMD Radeon R9 M395
  • MacBook (Early 2015), 1.3GHz Core M, Intel HD 5300
  • iPad Pro 10.5", 256GB
Link to comment
Share on other sites

  • Staff

ok - but what is the pure number?  For trig functions do you expect it in degrees or radians?  Our angle type allows for conversion between degrees and radians internally, but to convert it to a pure number you need some notion of what angular units you are using.

All the C functions we call work in radians.

SerifLabs team - Affinity Developer
  • Software engineer  -  Photographer  -  Guitarist  -  Philosopher
  • iMac 27" Retina 5K (Late 2015), 4.0GHz i7, AMD Radeon R9 M395
  • MacBook (Early 2015), 1.3GHz Core M, Intel HD 5300
  • iPad Pro 10.5", 256GB
Link to comment
Share on other sites

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.