Skip to content

proposal: math: add deg <-> rad conversion constants #19587

@niondir

Description

@niondir

I was doing some image processing and with rotation I noticed that all the trigonometric functions are operating on rads. But people can better think in deg e.g. "I want to turn my picture by 90°" and not by 1,5708 rads.

I would like to add some constants to the math package:

// Trigonometric constants.
const (
	DegToRad = 0.017453292519943295769236907684886127134428718885417 // N[Pi/180, 50]
	RadToDeg = 57.295779513082320876798154814105170332405472466564   // N[180/Pi, 50]

	GradToRad = 0.015707963267948966192313216916397514420985846996876 // N[Pi/200, 50]
	RadToGrad = 63.661977236758134307553505349005744813783858296183   // N[200/Pi, 50]
)

What version of Go are you using (go version)?

1.8

What operating system and processor architecture are you using (go env)?

windows amd64

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions