Re: [csswg-drafts] [css-values-4] How should atan2 behave with different length units? (#7482)

> Should 10vw be computed and converted into px? What if the terms were reversed? Should 10px be converted to vw then?

It doesn't matter. `atan2(Y, X)` only depends on `Y / X` and the sign of `X`. So let's say `1vw = k * 1px`, where `k > 0`.

Then `atan2(90px, 90vw)` can use `90px / (k * 90px) = 1 / k` and `sign(k * 90px) = 1`.
Or it can use `(90vw / k) / 90vw = 1 / k` and `sign(90vw) = 1`. No difference.

> If percentages are allowed, then what are they a percentage of?

It depends. Percentages may have the type «[ "percent" → 1 ]» e.g. in `opacity`. Then you just use the ratio between the numerical parts of the percentages, and the sign.

But in properties like `width`, where a percentage resolves into a length, the type is «[ "length" → 1 ]». So what you do is resolve the percentage as specified in the property (in `width`, against the width of the containing block), and then just do the division with the resulting length.

> What should happen if a calculation cannot be simplified to a single number?

See https://drafts.csswg.org/css-values-4/#calc-computed-value. Maybe not at specified value time, maybe not at computed value time either, but: "with used value time information, a [math function](https://drafts.csswg.org/css-values-4/#math-function) always simplifies down to a single numeric value."

> why does this function accept units at all?

Because it's more flexible and it's well-defined. Math functions that can accept dimensions do so: `min`, `max`, `clamp`, `round`, `mod`, `rem`, `hypot`, `abs`, `sign`.

-- 
GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7482#issuecomment-1179783883 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Sunday, 10 July 2022 19:21:58 UTC