When you were learning trigonometry, you probably measured angles in degrees. But in calculus, angles are measured in radians (search for "degrees vs. radians" on Google for the reasons). Being able to convert between these two units might be handy. PHP provides two functions for this purpose, but no such luck in ASP. As usual, we're going to write our own.

Radians is heavily based on my favorite number, pi. We're going to need this number in our calculations, so make sure to define a constant for it.

`Const M_PI = 3.14159265358979323846`

And now the functions themselves...

`function deg2rad(x)`

`deg2rad = x * M_PI / 180`

`end function`

`function rad2deg(x)`

`rad2deg = x * 180 / M_PI`

`end function`

## No comments:

Post a Comment