-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from oakmound/release/2.0.0
Oak 2.0.0
- Loading branch information
Showing
298 changed files
with
11,914 additions
and
3,923 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package alg | ||
|
||
import "math" | ||
|
||
const ( | ||
// DegToRad is the constant value something in | ||
// degrees should be multiplied by to obtain | ||
// something in radians. | ||
DegToRad = math.Pi / 180 | ||
// RadToDeg is the constant value something in | ||
// radians should be multiplied by to obtain | ||
// something in degrees. | ||
RadToDeg = 180 / math.Pi | ||
) | ||
|
||
// We might not want these types | ||
// It might be too much of a hassle to deal with them | ||
|
||
// A Radian value is a float that specifies it should be in radians. | ||
type Radian float64 | ||
|
||
// Degrees converts a Radian to Degrees. | ||
func (r Radian) Degrees() Degree { | ||
return Degree(r * RadToDeg) | ||
} | ||
|
||
// A Degree value is a float that specifies it should be in degrees. | ||
type Degree float64 | ||
|
||
// Radians converts a Degree to Radians. | ||
func (d Degree) Radians() Radian { | ||
return Radian(d * DegToRad) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package alg | ||
|
||
import ( | ||
"math" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestDegrees(t *testing.T) { | ||
var f Degree = 90 | ||
assert.Equal(t, Radian(f*DegToRad), f.Radians()) | ||
var f2 Radian = math.Pi / 2 | ||
assert.Equal(t, Degree(f2*RadToDeg), f2.Degrees()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.