DEGREES() Function in MySQL
Last Updated :
01 Oct, 2020
DEGREES() function in MySQL is used to convert the radian values into degrees. The formula for converting radian to degree is :
Ï€ radian = 180 degrees
Syntax :
DEGREES(X)
Parameter : This method accepts only one parameter.
X : The radian value which we convert to degrees.
Returns : It returns equivalent radian values into degrees.
Example-1 : Finding Degree Value for 0 radian using DEGREES Function.
SELECT DEGREES(0) AS Degree_Value;
Output :
Example-2 : Finding Degree Value for 3.141592653589793 radian using DEGREES Function.
SELECT DEGREES(3.141592653589793) AS Degree_Value;
Output :
Example-3 : Finding Degree Value for -1.5707963267948966 radian using DEGREES Function.
SELECT DEGREES(-1.5707963267948966 ) AS Degree_Value;
Output :
Example-4 : Using RADIANS Function to convert degrees from radian for a column data. To demonstrate, let us create a table named Polygon.
CREATE TABLE Polygon (
Shape VARCHAR(100) NOT NULL,
Sides INT NOT NULL,
Sum_of_Interior_Angles DECIMAL(10, 2) NOT NULL,
Each_Angle DECIMAL(10, 2) NOT NULL,
PRIMARY KEY(Sides)
);
Now, insert some data to the Polygon table –
INSERT INTO
Polygon(Shape, Sides, Sum_of_Interior_Angles, Each_Angle)
VALUES
('Triangle', 3, 3.141592653589793, 1.0471975511965976),
('Quadrilateral', 4, 6.283185307179586, 1.5707963267948966),
('Pentagon', 5, 9.42477796076938, 1.8849555921538759),
('Hexagon', 6, 12.566370614359172, 2.0943951023931953),
('Heptagon', 7, 15.707963267948966, 2.2439698192891093),
('Octagon', 8, 18.84955592153876, 2.356194490192345),
('Nonagon', 9, 21.991148575128552, 2.443460952792061),
('Decagon', 10, 25.132741228718345, 2.5132741228718345);
So, the Polygon Table is –
SELECT * FROM Polygon;
Shape |
Sides |
Sum_of_Interior_Angles |
Each_Angle |
Triangle |
3 |
3.14159265358979300000 |
1.0471975511965976 |
Quadrilateral |
4 |
6.28318530717958600000 |
1.5707963267948966 |
Pentagon |
5 |
9.42477796076938 |
1.8849555921538759 |
Hexagon |
6 |
12.566370614359172 |
2.0943951023931953 |
Heptagon |
7 |
15.707963267948966 |
2.2439698192891093 |
Octagon |
8 |
18.84955592153876 |
2.356194490192345 |
Nonagon |
9 |
21.991148575128552 |
2.443460952792061 |
Decagon |
10 |
25.132741228718345 |
2.5132741228718345 |
We can see that sum of interior angles and each angle of the polygon are given in radian. Now we will convert these into degrees with the help of DEGREES Function.
SELECT Shape, Sides,
DEGREES(Sum_of_Interior_Angles) AS Sum_of_Interior_Angles_InDegree,
DEGREES(Each_Angle) AS Each_Angle_InDegree
FROM Polygon;
Output :
Shape |
Sides |
Sum_of_Interior_Angles_InDegree |
Each_Angle_InDegree |
Triangle |
3 |
180 |
59.99999999999999 |
Quadrilateral |
4 |
360 |
90 |
Pentagon |
5 |
540 |
108 |
Hexagon |
6 |
720 |
119.99999999999999 |
Heptagon |
7 |
900 |
128.57 |
Octagon |
8 |
1080 |
135 |
Nonagon |
9 |
1260 |
140 |
Decagon |
10 |
1440 |
144 |
So, here the sum of all interior angle, and each angle are converted to equivalent degree value.
Share your thoughts in the comments
Please Login to comment...