SQL Server/T-SQL Tutorial/Math Functions/Sin

Материал из SQL эксперт
Перейти к: навигация, поиск

Sin, COS and Tan

4> DECLARE @degrees smallint
5> DECLARE @radians float
6> SELECT @degrees=0
7> SELECT @radians=0
8> WHILE (@degrees <= 180)
9> BEGIN
10>     SELECT
11>     DEGREES=@degrees,
12>     RADIANS=STR(@radians, 8, 5),
13>     SINE=STR(SIN(@radians), 8, 5),
14>     COSINE=STR(COS(@radians), 8, 5),
15>     TANGENT=STR(TAN(@radians), 8, 5)
16>     SELECT @degrees=@degrees + 10
17>     SELECT @radians=RADIANS(CONVERT(float, @degrees))
18> END
19> GO
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
      0  0.00000  0.00000  1.00000  0.00000
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
     10  0.17453  0.17365  0.98481  0.17633
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
     20  0.34907  0.34202  0.93969  0.36397
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
     30  0.52360  0.50000  0.86603  0.57735
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
     40  0.69813  0.64279  0.76604  0.83910
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
     50  0.87266  0.76604  0.64279  1.19175
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
     60  1.04720  0.86603  0.50000  1.73205
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
     70  1.22173  0.93969  0.34202  2.74748
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
     80  1.39626  0.98481  0.17365  5.67128
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
     90  1.57080  1.00000  0.00000 ********
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
    100  1.74533  0.98481 -0.17365 -5.67128
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
    110  1.91986  0.93969 -0.34202 -2.74748
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
    120  2.09440  0.86603 -0.50000 -1.73205
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
    130  2.26893  0.76604 -0.64279 -1.19175
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
    140  2.44346  0.64279 -0.76604 -0.83910
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
    150  2.61799  0.50000 -0.86603 -0.57735
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
    160  2.79253  0.34202 -0.93969 -0.36397
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
    170  2.96706  0.17365 -0.98481 -0.17633
(1 rows affected)
DEGREES RADIANS  SINE     COSINE   TANGENT
------- -------- -------- -------- --------
    180  3.14159  0.00000 -1.00000 -0.00000
(1 rows affected)
1>


SIN returns a float value that is the sine of the angle passed in as a parameter.

Note that the angle passed in must be in radians.
5> SELECT SIN(1.2)
6> GO
------------------------
     0.93203908596722629
(1 rows affected)