-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-values] Make 'hypot()' n-dimensional #3765
Comments
I definitely like the idea of supporting a 3-value I can't think of any use cases for more dimensions on the web, but don't think it would complicate the implementation. The ECMAScript I think it confuses matters a bit to talk about |
Allowing 2+ arguments sounds great, I'm sorry I forgot about it initially. ^_^ Allowing a single argument to effectively be |
@tabatkins "the length of an N-dimensional vector" is not clear enough, you should specify that it's the euclidean norm, since vector spaces can have other kinds of norms. |
Technically, yes. But euclidean norm is always assumed if not specified and there's nothing else in the context hinting that you might be talking about other norms. If someone comes at me with some Manhattan distance, I'm gonna assume they're being a smart-ass. ^_^ |
It wouldn't hurt to specify the actual calculation (“the square root of the sum of squares of its arguments”, to use the ECMAScript text) for clarity. People who haven't taken advanced math may be confused by "the length of an N-dimensional vector", with or without specifying Euclidean space. |
Shouldnʼt the function better be called (I obviously donʼt value compatibility with JS nomenclature as highly as others; also dislike redundant |
Good point, I've done so.
The JS-naming concordance besides, it's still also a hypotenuse of the right triangle defined by the origin, the point given by the first N-1 arguments, and the point given by all the arguments. |
… except in the degenerate case with a single argument. |
Nope, it's still the hypotenuse there. The point given by the first N-1 arguments is the origin, because there are no arguments at all. The triangle is thus degenerate, but it still has a meaningful "hypotenuse", which is equal to the absolute value of the provided argument. |
BTW, should |
At that point I really think it's a step too far. Unlike 1-arg hypot() (which gives us abs()), another way of writing 0 doesn't seem useful. |
From https://drafts.csswg.org/css-values-4/#funcdef-hypot,
I would like to generalize this to the euclidean norm like in JS
Math.hypot
. Thenhypot(A)
would be the absolute value of Ahypot(A, B)
would be the hypotenuse of a right-angled triangle with legs equal to A and B.hypot(A, B, C)
would be the length of the space diagonal of a rectangular cuboid with edge lengths A, B and C.The text was updated successfully, but these errors were encountered: