RADIANS() Function in MySQL
Last Updated :
30 Sep, 2020
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 :
RADIANS(X)
Parameter : This method accepts only one parameter.
X : The degree value which we convert to radian.
Returns : It returns equivalent degree values into radians.
Example-1 :
Finding Radians Value for 0 degree using RADIANS Function.
SELECT RADIANS(0) AS Radian_Value;
Output :
Example-2 :
Finding Radians Value for 180 degree using RADIANS Function.
SELECT RADIANS(180) AS Radian_Value;
Output :
Radian_Value |
3.141592653589793 |
Example-3 :
Finding Radians Value for -90 degree using RADIANS Function.
SELECT RADIANS(-90) AS Radian_Value;
Output :
Radian_Value |
-1.5707963267948966 |
Example-4 :
Using RADIANS Function to convert radian from a degree 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, 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, the Polygon Table is -
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 |
We can see that sum of interior angles and each angle of the polygon are given in degrees. Now we will convert these into radians with the help of RADIAN Function.
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 the sum of an interior angle, and each angle are converted to equivalent radian value.
Similar Reads
RPAD() Function in MySQL
RPAD() function in MySQL is used to pad or add a string to the right side of the original string. Syntax : RPAD(str, len, padstr) Parameter : This function accepts three parameter as mentioned above and described below : str : The actual string which is to be padded. If the length of the original st
1 min read
RAND() Function in MySQL
The RAND() function in MySQL is used to a return random floating-point value V in the range 0 <= V < 1.0. If we want to obtain a random integer R in the range i <= R < j, we have to use the expression : FLOOR(i + RAND() * (j â i)). Syntax : RAND(N) Parameter : This method accepts only on
3 min read
TAN() Function in MySQL
TAN() function : This function in MySQL is used to return the tangent of a specified number. In any right triangle, the tangent of an angle is the length of the opposite side divided by the length of the adjacent side. Similarly, this can also be defined as tangent of x is the sine of x divided by t
1 min read
ORD() Function in MySQL
ORD() function in MySQL is used to find the code of the leftmost character in a string . If the leftmost character is not a multibyte character, it returns ASCII value. And if the leftmost character of the string str is a multibyte character, ORD returns the code for that character, calculated from
3 min read
TRIM() Function in MySQL
TRIM() function in MySQL is used to clean up data. It is also used to remove the unwanted leading and trailing characters in a string. Syntax : TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str) Parameter : This method accepts three-parameter as mentioned above and described below : BOTH | LEADIN
2 min read
SIGN() Function in MySQL
SIGN() function in MySQL is used to return the sign of the given number. It returns 1 if the number is positive, -1 if the number is negative and 0 for zero. Syntax : SIGN(X) Parameter : SIGN() function accepts one parameter as input and will give you the results in values like Positive(+1),Negative
1 min read
PI() function in MySQL
PI() function in MySQL is used to return the Pi value. The default number of decimal places displayed is seven, but MySQL uses the full double-precision value internally. Syntax : PI() Parameter : This method does not accept any parameter. Returns : It returns the Pi value i.e. 3.141593. Example-1 :
2 min read
RTRIM() Function in MySQL
RTRIM() : It is the function in MySQL that is used to remove trailing spaces from a string. Syntax : RTRIM(str) Parameter : RTRIM() function accepts one parameter as mentioned above and described below. str âThe string from which we want to remove trailing spaces. Returns : It returns a string after
3 min read
RIGHT() Function in MySQL
RIGHT() function in MySQL is used to extract a specified number of characters from the right side of a given string. Second argument is used to decide, how many characters it should return. Syntax : RIGHT( str, len ) Parameter : This function accepts two parameter as mentioned above and described be
3 min read
SUM() Function in MySQL
The SUM() function in MySQL is a powerful aggregate function used to calculate the total sum of values in a numeric column. By summing up the values in the specified column, this function helps in generating overall totals and performing calculations that provide meaningful insights from our data. I
4 min read