Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert radians to degree / degree to radians

Are there build-in functions in R for the conversion of radians to degree and degree to radians?

So far I wrote my one own functions:

rad2deg <- function(rad) {(rad * 180) / (pi)}
deg2rad <- function(deg) {(deg * pi) / (180)}

#test:
rad2deg(pi) #180
rad2deg(2*pi) #360
deg2rad(180) #pi
like image 241
Iris Avatar asked Sep 03 '15 08:09

Iris


People also ask

How do you convert from radians to degrees?

How To Convert Radians to Degrees? The conversion of measure of an angle from radians to degrees can be done using the following formula: Angle in Radians × 180°/π = Angle in Degrees. For example, consider an angle π/9 rad. Now, using the radians to degrees formula, we have π/9 rad × 180°/π = (Angle in Degrees).

Why pi radians is 180 degrees?

The value of 180 degrees in radians is π. Because 2π = 360 degrees. When we divide both sides by 2, we get π = 180 degrees.

How do you convert from radians to pies?

So one radian = 180/ PI degrees and one degree = PI /180 radians. Therefore to convert a certain number of degrees in to radians, multiply the number of degrees by PI /180 (for example, 90º = 90 × PI /180 radians = PI /2). To convert a certain number of radians into degrees, multiply the number of radians by 180/ PI .


2 Answers

The comment of Pascal was very useful and I found several ones, e.g.

install.packages("NISTunits", dependencies = TRUE)
library(NISTunits)

NISTdegTOradian(180)
NISTradianTOdeg(pi)
like image 60
Iris Avatar answered Oct 12 '22 05:10

Iris


You can use the units package for this.

library(units)
pi_rad <- as_units(pi, "radians")
pi_deg <- set_units(pi_rad, "degrees")
set_units(pi_deg, "radians")
like image 29
jsta Avatar answered Oct 12 '22 05:10

jsta