Skip to content

Commit

Permalink
feat(angle): support deg text for angle
Browse files Browse the repository at this point in the history
Uses deg text in addition to the current way of
using the degree symbol. It also aligns with
how we use "rad" for radians.
  • Loading branch information
christka1 committed Aug 29, 2024
1 parent 8dda04a commit dca0058
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions angle.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const Degree = Radian / 180 * math.Pi

const degreeSymbol = "°"

const degreeText = "deg"

// Radians returns the angle with the unit of radians.
func (a Angle) Radians() float64 {
return float64(a)
Expand Down Expand Up @@ -76,6 +78,7 @@ func (a *Angle) UnmarshalString(s string) error {
parsed, err := parse(s, map[string]float64{
radianSymbol: float64(Radian),
degreeSymbol: float64(Degree),
degreeText: float64(Degree),
})
if err != nil {
return fmt.Errorf("unmarshal angle: %w", err)
Expand Down

0 comments on commit dca0058

Please sign in to comment.