The trigonometric operations and geometric manipulation are usually done in radians; it is always useful to be able to convert these into degrees and vice versa. This recipe will show you some tips on how to handle the conversion between these units.
Converting between degrees and radians
How to do it...
- Open the console and create the folder chapter03/recipe10.
- Navigate to the directory.
- Create the radians.go file with the following content:
package main
import (
"fmt"
"math"
)
type Radian float64
func (rad Radian) ToDegrees() Degree {
return Degree(float64(rad) * (180.0 / math.Pi))
}
func (rad Radian) Float64() float64 {
...