Skip to content

Commit

Permalink
#4
Browse files Browse the repository at this point in the history
  • Loading branch information
yakir12 committed Jul 28, 2017
1 parent 152d877 commit 7a1d82f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,38 @@ A supplemental units package for [Julia](https://julialang.org)'s [Unitful.jl](h

In addition to the `Radian` and `Degree` units already available in `Unitful.jl`, the following units are introduced: `Turn`, `HalfTurn`, `Quadrant`, `Sextant`, `Octant`, `ClockPosition`, `HourAngle`, `CompassPoint`, `Hexacontade`, `BinaryRadian`, `DiameterPart`, `Gradian`, `Arcminute`, and `Arcsecond`.

Because all the trigonometric functions work correctly regardless of the type of their argument, there is no need to convert between the units. However, to specifically convert one unit to the other, use `Unitful.jl`'s `uconvert` function:
```julia
julia> using Unitful

julia> uconvert(u"clockPosition", 128u"brad")
6//1 clockPosition
```

## Special features

- All the trigonometric functions (`sin`, `sinc`, `cos`, `cosc`, `tan`, `sec`, `csc`, and `cot`) work as expected:
```julia
julia> using UnitfulAngles

julia> sin(30u"°")
julia> import UnitfulAngles: °, rad, octant

julia> sin(30°)
0.5

julia> cos*u"rad")
julia> cos*rad)
-1.0

julia> tan(1u"octant")
julia> tan(1octant)
1.0
```

- In order to get inverse functions (`acos`, `acot`, `acsc`, `asec`, `asin`, `atan`, and `atan2`) to return a specific unit, specify the desired unit as the first argument:
```julia
julia> asin(u"turn", 1)
0.25 τ
```

Because all the trigonometric functions work correctly regardless of the type of their argument, there is no need to convert between the units. However, to specifically convert one unit to the other, use `Unitful.jl`'s `uconvert` function:
```julia
julia> using Unitful
julia> import UnitfulAngles.turn

julia> uconvert(u"clockPosition", 128u"brad")
6//1 clockPosition
julia> asin(turn, 1)
0.25 τ
```

- As a bonus, you can also convert between an angle and `Dates.Time`:
```julia
julia> convert(Dates.Time, 200u"grad")
Expand Down
1 change: 1 addition & 0 deletions src/UnitfulAngles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module UnitfulAngles

using Unitful
using Unitful: @unit, Quantity, NoDims, FreeUnits
import Unitful: °, rad
import Base: sin, cos, tan, sec, csc, cot, asin, acos, atan, asec, acsc, acot, atan2, convert
export @u_str

Expand Down

0 comments on commit 7a1d82f

Please sign in to comment.