How the RADIANS() function works in Mariadb?

The RADIANS() function is a mathematical function in Mariadb that returns the value of an angle in radians.

Posted on

The RADIANS() function is a mathematical function in Mariadb that returns the value of an angle in radians. The function can be used to convert an angle from degrees to radians, which is useful for performing trigonometric calculations, such as finding the sine, cosine, or tangent of an angle.

Syntax

The syntax of the RADIANS() function is as follows:

RADIANS(angle)

The function takes one argument:

  • angle: A numeric expression that represents the angle in degrees. The angle can be any valid numeric value, such as an integer, a decimal, or a fraction. The angle cannot be NULL.

The function returns a numeric value that represents the angle in radians, as follows:

  • The function converts the angle from degrees to radians by multiplying it by $$\frac{\pi}{180}$$, where $$\pi$$ is the mathematical constant that is approximately equal to 3.14159. The function returns the result of the conversion.
  • If the angle is NULL, the function returns NULL.

Examples

Example 1: Converting an angle from degrees to radians

The following example converts an angle of 90 degrees to radians using the RADIANS() function.

SELECT RADIANS(90) AS radians;

The output is:

+--------------------+
| radians            |
+--------------------+
| 1.5707963267948966 |
+--------------------+

The output shows that the angle of 90 degrees is equivalent to 1.5708 radians, as 90 * \frac{\pi}{180} = 1.5708.

Example 2: Converting an angle from degrees to radians with a decimal value

The following example converts an angle of 45.5 degrees to radians using the RADIANS() function.

SELECT RADIANS(45.5) AS radians;

The output is:

+--------------------+
| radians            |
+--------------------+
| 0.7941248096574199 |
+--------------------+

The output shows that the angle of 45.5 degrees is equivalent to 0.79412 radians, as 45.5 * \frac{\pi}{180} = 0.79412.

Example 3: Converting an angle from degrees to radians with a fraction value

The following example converts an angle of $$\frac{3}{4}$$ degrees to radians using the RADIANS() function.

SELECT RADIANS(3/4) AS radians;

The output is:

+----------------------+
| radians              |
+----------------------+
| 0.013089969389957472 |
+----------------------+

The output shows that the angle of $$\frac{3}{4}$$ degrees is equivalent to 0.013089 radians, as 0.75 * \frac{\pi}{180} = 0.013089.

There are some other functions that are related to the RADIANS() function, such as:

  • DEGREES(): This function returns the value of an angle in degrees. The function can be used to convert an angle from radians to degrees, which is useful for displaying or comparing angles in a more familiar unit. The syntax of the function is DEGREES(angle), where angle is a numeric expression that represents the angle in radians. The function returns a numeric value that represents the angle in degrees.
  • SIN(): This function returns the sine of an angle. The sine of an angle is a trigonometric function that measures the ratio of the opposite side to the hypotenuse of a right triangle. The syntax of the function is SIN(angle), where angle is a numeric expression that represents the angle in radians. The function returns a numeric value that represents the sine of the angle.
  • COS(): This function returns the cosine of an angle. The cosine of an angle is a trigonometric function that measures the ratio of the adjacent side to the hypotenuse of a right triangle. The syntax of the function is COS(angle), where angle is a numeric expression that represents the angle in radians. The function returns a numeric value that represents the cosine of the angle.
  • TAN(): This function returns the tangent of an angle. The tangent of an angle is a trigonometric function that measures the ratio of the opposite side to the adjacent side of a right triangle. The syntax of the function is TAN(angle), where angle is a numeric expression that represents the angle in radians. The function returns a numeric value that represents the tangent of the angle.

Conclusion

The RADIANS() function is a useful function to return the value of an angle in radians. The function can be used to convert an angle from degrees to radians, which is useful for performing trigonometric calculations, such as finding the sine, cosine, or tangent of an angle. The function takes one argument, which is a numeric expression that represents the angle in degrees.

The function can also be combined with other mathematical functions, such as DEGREES(), SIN(), COS(), TAN(), etc., to perform more complex operations on angles.