Skip to content

Commit 3ed7e84

Browse files
authored
Merge pull request #3761 from w3c/AmeliaBR-patch-trig
[css-values-4] Clean up trig function definitions
2 parents 054ba11 + 004638a commit 3ed7e84

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

css-values-4/Overview.bs

+17-13
Original file line numberDiff line numberDiff line change
@@ -2472,13 +2472,13 @@ Trigonometric Functions: ''sin()'', ''cos()'', ''tan()'', ''asin()'', ''acos()''
24722472
''sin()'', ''cos()'', ''tan()'', ''asin()'', ''acos()'', ''atan()'', and ''atan2()''--
24732473
compute the various basic trigonometric relationships.
24742474

2475-
The <dfn lt="sin()">sin(A)</dfn>, <dfn lt="cos(A)">cos()</dfn>, and <dfn lt="tan()">tan(A)</dfn> functions
2475+
The <dfn lt="sin()">sin(A)</dfn>, <dfn lt="cos()">cos(A)</dfn>, and <dfn lt="tan()">tan(A)</dfn> functions
24762476
all contain a single [=calculation=]
24772477
which must resolve to either a <<number>>
24782478
or an <<angle>>,
24792479
and compute their corresponding function
24802480
by interpreting the result of their argument as radians.
2481-
(That is, ''sin(45deg)'', ''sin(.125)'', and ''sin(3.14159 / 4 * 1rad)''
2481+
(That is, ''sin(45deg)'', ''sin(.125turn)'', and ''sin(3.14159 / 4)''
24822482
all represent the same value,
24832483
approximately ''.707''.)
24842484
They all represent a <<number>>;
@@ -2499,21 +2499,23 @@ Trigonometric Functions: ''sin()'', ''cos()'', ''tan()'', ''asin()'', ''acos()''
24992499
and the angle returned by ''atan()'' to the range [''-90deg'', ''90deg''].
25002500

25012501
The <dfn lt="atan2()">atan2(A, B)</dfn> function
2502-
contains two comma-separated [=calculations=] A and B
2503-
that must resolve to <<number>>s,
2504-
and returns the <<angle>>
2502+
contains two comma-separated [=calculations=], A and B.
2503+
A and B can resolve to any <<number>>, <<dimension>>, or <<percentage>>,
2504+
but must have the <em>same</em> [=determine the type of a calculation|type=],
2505+
or else the function is invalid.
2506+
The function returns the <<angle>>
25052507
between the positive X-axis and the point (B,A).
25062508
The returned angle must be normalized to the interval (''-180deg'', ''180deg'']
25072509
(that is, greater than ''-180deg'', and less than or equal to ''180deg'').
25082510

25092511
Note: ''atan2(Y, X)'' is <em>generally</em> equivalent to ''atan(Y / X)'',
2510-
but it gives a better answer when the point in question is in the second (NW) or third (SW) quadrants of the plane.
2511-
''atan2(1, -1)'', corresponding to the point (-1, 1) in the NW of the plane,
2512+
but it gives a better answer when the point in question may include negative components.
2513+
''atan2(1, -1)'', corresponding to the point (-1, 1),
25122514
returns ''135deg'',
2513-
distinct from ''atan2(-1, 1)'', corresponding to the point (1, -1) in the SE of the plane,
2515+
distinct from ''atan2(-1, 1)'', corresponding to the point (1, -1),
25142516
which returns ''-45deg''.
2515-
However, as ''1 / -1'' and ''-1 / 1'' both resolve to ''-1'',
2516-
''atan()'' returns the same ''-45deg'' for both points.
2517+
In contrast, ''atan(1 / -1)'' and ''atan(-1 / 1)'' both return''-45deg'',
2518+
because the internal calculation resolves to ''-1'' for both.
25172519

25182520

25192521
<h4 id="trig-infinities">
@@ -2603,6 +2605,7 @@ Exponential Functions: ''pow()'', ''sqrt()'', ''hypot()''</h3>
26032605
and then the ''pow(X, 1/3)'' would cube-root the value back down to 30 and multiply the exponent by 1/3,
26042606
giving «[ "length" → 1 ]»,
26052607
which [=CSSNumericValue/matches=] <<length>>.
2608+
26062609
In the realm of pure mathematics, that's guaranteed to work out;
26072610
in the real-world of computers using binary floating-point arithmetic,
26082611
in some cases the powers might not exactly cancel out,
@@ -2652,7 +2655,8 @@ Exponential Functions: ''pow()'', ''sqrt()'', ''hypot()''</h3>
26522655
as the inputs and output all have the same type.
26532656
The result isn't unit-dependent, either,
26542657
due to the nature of the operation;
2655-
''hypot(3em, 4em)'' and ''hypot(48px, 64px)'' give the same result in both cases:
2658+
''hypot(3em, 4em)'' and ''hypot(48px, 64px)'' both result in the same length
2659+
when ''1em'' equals ''16px'':
26562660
''5em'' or ''80px''.
26572661
Thus it's fine to let author use dimensions directly in ''hypot()''.
26582662
</details>
@@ -2986,14 +2990,14 @@ Computed Value</h3>
29862990
so implementations can simplify the expressions
29872991
further than what is required here
29882992
when storing the values internally;
2989-
in particular, all [=math function=] expressions can be reduced
2993+
in particular, all [=calculation=] expressions can be reduced
29902994
to a sum of a <<number>>, a <<percentage>>, and some <<dimension>>s,
29912995
eliminating all multiplication or division,
29922996
and combining terms with identical units.
29932997

29942998
At this time, all units can be absolutized
29952999
to a single unit per type at computed-value time,
2996-
so at that point the [=math function=] can be reduced
3000+
so at that point the [=calculation=] can be reduced
29973001
to just a <<number>>, a <<percentage>>, and a single absolute <<dimension>> of the appropriate type,
29983002
per expression.
29993003
</div>

0 commit comments

Comments
 (0)