# Inconsistencies in field input expressions

## Recommended Posts

Sometimes, when using some mathematical functions in input fields, the Unit Of Measure needs to be given for the expression to be calculated.
For example, when I enter “+=cos(30)*10” (without the quotes) into the X field of the Transform Panel there is no effect, but entering “+=cos(30)*10 mm” (with the UOM) moves the selected layer as expected.
Also, entering “x+cos(30)*10” (no UOM) into the X field yields no movement while entering “x+cos(30)*10 mm” (with UOM) also yields no movement, so providing the UOM is no guarantee of an expected result.
However, entering “x+fraction(2.5)” (no UOM) does produce a movement.
This behaviour is inconsistent.

This happens on both Windows and OS X (no reports so far for iPad so I don’t know what happens there).
This has only been checked in Designer (as far as I know) but all apps need testing, with expressions of differing complexity.

Also, the Help for this needs to be expanded with better explanations of what each function does and example usage. For example, the Help lists “cos(t)” as a function but doesn’t say whether “t” should be in degrees or radians. Most functions don’t even have a description, which is a bit limiting.
Basically the Help for this should contain much more information but the most important thing (in this case) is to get the functions working consistently.

See the discussion (with a small test result table) here: https://forum.affinity.serif.com/index.php?/topic/104444-transforming-an-object-relative-to-its-position/&

##### Share on other sites

Hey @GarryP,

Trigonometry functions require units to work. Otherwise, that "value" can be anything.

As for the second example, "x +" requires a distance value, so the "cos(30)*10" needs to be converted to mm before the "+" can be applied. So, x+(cos(30)*10 mm) works.

##### Share on other sites

Thanks for picking this up Gabe.

I would have expected, as do some other people in the linked thread, that the 10 in x+cos(30)*10 would default to the document units in the same way that, by way of two examples, x+10 and x+fraction(2.5) do. As that’s not the case, I think this needs to be documented in some way so users know when they need to use units or don’t need to use them. For instance, is it only the trig functions or others too? If it’s explicit in the documentation then people can know what’s what.

There’s also the situation where x+cos(30)*10mm does not do anything but x+(cos(30)*10mm) does, note the extra parentheses used. There’s nothing in the documentation to explain where parentheses are needed or not and in which situations.

I think both of these things need to be documented – along with more general info’ as requested above – as there’s no feedback to tell the user that they have entered an equation incorrectly; the value just ‘springs back’ to the last value and the user could just assume that it’s worked.

##### Share on other sites
On 1/7/2020 at 1:05 PM, Gabe said:

Hey @GarryP,

Trigonometry functions require units to work. Otherwise, that "value" can be anything.

As for the second example, "x +" requires a distance value, so the "cos(30)*10" needs to be converted to mm before the "+" can be applied. So, x+(cos(30)*10 mm) works.

That's just a poor excuse for a poorly written expression parser.

cos(60 degrees) evaluates to 0.5

We can write x+0.5*10 and document units is assumed, so we should be able to write x+cos(60)*10 and document units be assumed.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×

×

• #### Affinity

×
• Create New...