# Angle package

**URL:** <https://discourse.julialang.org/t/angle-package/4832>\
**Category:** Community\
**Tags:** package, announcement\
**Created:** [July 13, 2017, 9:55am UTC](https://discourse.julialang.org/t/angle-package/4832 "2017-07-13T09:55:06Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [July 14, 2017, 8:52am UTC](https://discourse.julialang.org/t/angle-package/4832/21 "2017-07-14T08:52:56Z")

</div>

See [this discussion](https://math.stackexchange.com/questions/96151/do-imaginary-and-complex-angles-exist) and the very nice [paper](http://www.people.vcu.edu/~rhammack/reprints/cmj210-217.pdf) they mention.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [July 14, 2017, 9:05am UTC](https://discourse.julialang.org/t/angle-package/4832/22 "2017-07-14T09:05:22Z")

</div>

Thanks for that paper!  
Since complex angles are not entirely impossible, I don’t see why I should limit the scope of an `Angle` to only real numbers. I agree that it’s not super-common, but why limit it to reals if there might be a few users that want/need these to be imaginary?

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [July 14, 2017, 9:19am UTC](https://discourse.julialang.org/t/angle-package/4832/23 "2017-07-14T09:19:14Z")

</div>

@Tamas_Papp While searching for complex angles I stumbled on that page, but saw only the first answer (which says what I was expecting), my fault. Thanks for pointing to that, very nice indeed!

> [@yakir12](#):
>
> Since complex angles are not entirely impossible, I don’t see why I should limit the scope of an Angle to only real numbers.

Ok, there seems to be an interpretation (though it’s not widespread), but even interpreting complex numbers as hyperbolic angles, would you measure such “hyperbolic angles” in “degrees”?

> [@yakir12](#):
>
> I agree that it’s not super-common, but why limit it to reals if there might be a few users that want/need these to be imaginary?

If you were going to define most mathematical functions for a real type (in particular for `AbstractFloat`), you would automatically gain full support for complex numbers, because most complex functions in Julia standard library (except for special functions) are defined in terms of the real and imaginary part of the complex number. But probably this goes beyond the scope of this package.

For the record, this is what I do in [`Measurements.jl`](https://github.com/JuliaPhysics/Measurements.jl): the type defined in the package, `Measurement`, is subtype of `AbstractFloat` and I didn’t have to overload any complex-argument function, yet most complex functions happily accept `Complex{Measurement}` argument, including all trigonometric functions, both circular and hyperbolic.

Anyway, that was just a suggestion, I think I already extensively explained my point, I don’t want to push further the discussion, the package is your and the decision is up to you 😃

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [July 14, 2017, 9:47am UTC](https://discourse.julialang.org/t/angle-package/4832/24 "2017-07-14T09:47:27Z")

</div>

Thanks for pointing out what you did (I might bother you with questions on the details of how). I’m super grateful for any input anyone might have. I need it. Your way sounds cool, so I’m sure I’ll look into it. Thanks again!

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [July 14, 2017, 9:51am UTC](https://discourse.julialang.org/t/angle-package/4832/25 "2017-07-14T09:51:58Z")

</div>

> [@giordano](#):
>
> would you measure such “hyperbolic angles” in “degrees”?

Overall, I am fine with radians and multiples of π, so I wouldn’t, but for me the same applies to “real” angles. However, since the extension is basically costless, I would not hesitate to include it. It is hard to foresee all uses of a library, and when there are no tradeoffs, I would err on the side of generality.

The described solution for `Measurements.jl` is probably more useful.

---

<div class="post-metadata">

**Author:** ![waldyrious](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/waldyrious/32/80_2.png) [@waldyrious](https://discourse.julialang.org/u/waldyrious)\
**Post date:** [July 14, 2017, 11:14am UTC](https://discourse.julialang.org/t/angle-package/4832/26 "2017-07-14T11:14:29Z")

</div>

> [@Tamas\_Papp](#):
>
> multiples of π

Or [multiples of π/2](https://en.wikipedia.org/wiki/User:Waldir/Tau/Right_angle) 🙂

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [July 14, 2017, 12:34pm UTC](https://discourse.julialang.org/t/angle-package/4832/27 "2017-07-14T12:34:33Z")

</div>

Hmm, I added a “proportion” type to the `Angle` package (to complement and use the `sinpi` functions), but I now realize that I should have maybe named this new type “Multiple” instead… Thanks!

Done!

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [July 14, 2017, 1:50pm UTC](https://discourse.julialang.org/t/angle-package/4832/28 "2017-07-14T13:50:26Z")

</div>

> [@giordano](#):
>
> I mean, is there a physical meaning of “1.2 + 3.4im radians/degrees”?

This way lies madness. For centuries, people argued about whether _negative_ numbers are “physical”. Nowadays mathematicians prefer to ask whether something is applicable/useful and (or at least) logically consistent (so far as we know). Complex angles satisfy both of those tests.

For example, suppose you are integrating a function of angle (e.g. for a Fourier series) and you want to exploit the residue theorem, so you plug a complex angle (the location of a pole) into your function. Should it fail because you were representing your angles with an `Angle` type? Or because you were using degrees and call `deg2rad` somewhere?

> [@giordano](#):
>
> deg2rad and rad2deg aren’t defined for complex input in Julia

I didn’t realize that; they should be. ([define deg2rad and rad2deg for any Number by stevengj · Pull Request #22811 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/22811))

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [July 14, 2017, 2:26pm UTC](https://discourse.julialang.org/t/angle-package/4832/29 "2017-07-14T14:26:22Z")

</div>

> [@stevengj](#):
>
> This way lies madness. For centuries, people argued about whether negative numbers are “physical”.

At least I don’t have problems with negative numbers 😃

> [@stevengj](#):
>
> For example, suppose you are integrating a function of angle (e.g. for a Fourier series) and you want to exploit the residue theorem, so you plug a complex angle (the location of a pole) into your function. Should it fail because you were representing your angles with an Angle type? Or because you were using degrees and call deg2rad somewhere?

In Julia, making `Angle <: Real` wouldn’t prevent the use of `Complex{Angle}`, actually it might be even easier to work with complex quantities, so my proposal doesn’t limit anything 😉

Funnily enough, [it was you](https://github.com/JuliaPhysics/Measurements.jl/issues/1#issuecomment-220727239) who suggested me to make `Measurement <: Real` instead of `Number` just for this reason. I was wondering whether taking into account complex measurements, it turned out that in Julia it’s much easier to define the type as subtype of `Real`, support for complex numbers follows naturally 🙂

[Previous page](https://discourse.julialang.org/t/angle-package/4832.md?page=1)
