MySQL RADIANS() function
In this context, we will learn how we can use the MySQL RADIANS() function with proper syntax and good examples.
Introduction of MySQL RADIANS() function
RADIANS() function in MySQL is used to convert the degree values into radians. The formula for converting degree to radian is:
180 degrees = π radian
Syntax of the MySQL RADIANS() function
The syntax of the MySQL RADIANS() function is given as follows:
RADIANS(Y)
Parameters or arguments used in MySQL RADIANS() function:
Only one parameter is accepted by the RADIANS() function in MySQL, which is given as follows:
Y: This is the degree value which we want to convert to radian.
Returns: It will return equivalent degree values into radians.
Application used for RADIANS() function:
The RADIANS() function can be used in the given below MySQL versions.:
- MySQL 5.7
- MySQL 5.6
- MySQL 5.5
- MySQL 5.1
- MySQL 5.0
- MySQL 4.1
- MySQL 4.0
- MySQL 3.23
Examples of MySQL RADIANS() function:
Now we will look into some MySQL RADIANS() function examples and will explore how we can use the RADIANS function in MySQL.
Example 1:
Here, we will derive the Radians Value for 0 degrees using RADIANS Function in MySQL.
SELECT RADIANS(0) AS Radian_Value;
Output:
Radian_Value
0
1 row in set (0.00 sec)
Example 2:
Here, we will derive the Radians Value for 180 degrees using RADIANS Function in MySQL.
SELECT RADIANS(180) AS Radian_Value;
Output:
Radian_Value
3.141592653589793
1 row in set (0.00 sec)
Example 3:
In this example, we will find out the Radians Value for -90 degrees using RADIANS Function in MySQL.
SELECT RADIANS(-90) AS Radian_Value;
Output:
Radian_Value
-1.5707963267948966
1 row in set (0.00 sec)
Example 4:
When we require to convert radian from a degree of column data, then we can take the help of the RADIANS function in MySQL. For better understanding, we have created 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 we will add some data into the Polygon table.
INSERT INTO
Polygon(Shape, Sides, Sum_of_Interior_Angles, Each_Angle)
VALUES
('Triangle,' 3, 180, 60),
('Quadrilateral', 4, 360, 90),
('Pentagon,' 5, 540, 108),
('Hexagon', 6, 720, 120),
('Heptagon', 7, 900, 128.57),
('Octagon,' 8, 1080, 135),
('Nonagon', 9, 1260, 140),
('Decagon,' 10, 1440, 144);
So, here is the Polygon Table –
SELECT * FROM Polygon;
Shape | Sides | Sum_of_Interior_Angles | Each_Angle |
Triangle | 3 | 180.00 | 60.00 |
Quadrilateral | 4 | 360.00 | 90.00 |
Pentagon | 5 | 540.00 | 108.00 |
Hexagon | 6 | 720.00 | 120.00 |
Heptagon | 7 | 900.00 | 128.57 |
Octagon | 8 | 1080.00 | 135.00 |
Nonagon | 9 | 1260.00 | 140.00 |
Decagon | 10 | 1440.00 | 144.00 |
From the above, we can visualize that the sum of all interior angles and every angle of the Polygon is given in degrees form.
SELECT Shape, Sides,
RADIANS(Sum_of_Interior_Angles) AS Sum_of_Interior_Angles_InRadian,
RADIANS(Each_Angle) AS Each_Angle_InRadian
FROM Polygon;
Output:
Shape | Sides | Sum_of_Interior_Angles_InRadian | Each_Angle_InRadian |
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, here an equivalent radian value is converted from the sum of an interior angle and each angle.
Application of MySQL RADIANS() function:
This function is used to convert the degree values into radians.
Summary:
In the above context, we have learned how to use the RADIANS() function in MySQL to convert the degree values into radians.