/DimensionfulAngles.jl

An extension of Unitful.jl to include angles as a dimension.

Primary LanguageJuliaMIT LicenseMIT

Project Status: Active ā€“ The project has reached a stable, usable state and is being actively developed. CI codecov

DimensionfulAngles.jl

Extends Unitful.jl to include angle as a dimension and allow dispatching on angles.

Installation āš™

Install DimensionfulAngles.jl the usual way Julia packages are installed, i.e., using Julia package manager:

using Pkg
Pkg.add("DimensionfulAngles")

or in the Pkg REPL (enter from the Julia REPL with ]):

pkg> add DimensionfulAngles

Documentation šŸ“œ

Documentation of latest stable release. Documentation for the current code status in the <em>main</em> branch.

The full documentation can be found at https://cmichelenstrofer.github.io/DimensionfulAngles.

Basic Usage

Use DimensionfulAngles.jl for units containing angles and Unitful.jl for all other units. The units in DimensionfulAngles.jl are differentiated from their dimensionless counterparts with a subscript įµƒ. Simply add this subscript to any angle units to make it dimensionful. In Julia environments this can be typed as \^a<tab>.

julia> using Unitful

julia> using DimensionfulAngles

julia> dimensionless_angle = 1u"rad"

1 rad

julia> dimensionful_angle = 1u"radįµƒ"
1 rad

julia> typeof(dimensionless_angle)
Quantity{Int64, NoDims, Unitful.FreeUnits{(rad,), NoDims, nothing}}

julia> typeof(dimensionful_angle)
Quantity{Int64, š€, Unitful.FreeUnits{(rad,), š€, nothing}}

When defining quantities with units from DimensionfulAngles.jl you can use the ua string instead and omit the subscript įµƒ. But when defining quantities with units from both it is more convenient to use the u string.

julia> dimensionful_angle = 1ua"rad"
1 rad

julia> typeof(dimensionful_angle)
Quantity{Int64, š€, Unitful.FreeUnits{(rad,), š€, nothing}}

julia> angular_velocity = 1.2u"radįµƒ/s"
1.2 rad sā»Ā¹

julia> typeof(angular_velocity)
Quantity{Float64, š€ š“ā»Ā¹, Unitful.FreeUnits{(rad, sā»Ā¹), š€ š“ā»Ā¹, nothing}}

A third alternative is to directly import only the units you will be using and renaming those from DimensionfulAngles.jl to remove the superscript įµƒ.

julia> using Unitful

julia> using Unitful: m, s, kg

julia> using DimensionfulAngles: radįµƒ as rad, Ā°įµƒ as Ā°

julia> angular_velocity = 1.2rad / s
1.2 rad sā»Ā¹

Contributing

Contributor Covenant ColPrac: Contributor's Guide on Collaborative Practices for Community Packages SciML Code Style

Contributions are welcome! šŸŽŠ Please see the contribution guidelines for ways to contribute to the project.

Acknowledgments

  • Some portions of this software are adapted from:

    • UnitfulAngles.jl: Copyright (c) 2017: Yakir Luc Gagnon.
    • UnitfulUS.jl: Copyright (c) 2017, California Institute of Technology. All rights reserved.
  • The name DimensionfulAngles was suggested by @sostock.

  • This is an open source project. Thanks to all who have contributed! šŸŽŠšŸŽŠšŸŽŠ

Made with contrib.rocks.