<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>I do a lot of geometry and spherical-related work and i have never found an Angle type to be worth having. Always use radians. It’s what sin() and cos() take, it’s what graphics APIs like Cairo expect, it’s what graphics formats like SVG use. plus,, do you *really* want to be case-branching on every angle value? that really adds up when you’re converting 100,000s of lat-long pairs to cartesian.</div><div><br>On Jan 14, 2018, at 12:04 AM, BJ Homer via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html; charset=utf-8">An Angle type already exists in Foundation; see Measurement&lt;UnitAngle&gt;. You could add some convenience methods in an extension pretty easily.<div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">import</span> Foundation</div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170); background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">typealias</span><span style="color: #000000" class=""> Angle = </span>Measurement<span style="color: #000000" class="">&lt;</span>UnitAngle<span style="color: #000000" class="">&gt;</span></div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">extension</span> <span style="color: #703daa" class="">Measurement</span> <span style="color: #ba2da2" class="">where</span> UnitType == UnitAngle {</div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #ba2da2" class="">var</span> sine: <span style="color: #703daa" class="">Double</span> {</div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ba2da2" class="">let</span> radians = <span style="color: #ba2da2" class="">self</span>.<span style="color: #3e1e81" class="">converted</span>(to: .<span style="color: #703daa" class="">radians</span>).<span style="color: #703daa" class="">value</span></div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ba2da2" class="">return</span> <span style="color: #3e1e81" class="">sin</span>(radians)</div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; }</div></div><div class=""><p style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 13px;" class="">&nbsp;&nbsp; &nbsp;</p></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #ba2da2" class="">static</span> <span style="color: #ba2da2" class="">var</span> threeQuarterTurn: <span style="color: #4f8187" class="">Angle</span> {</div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ba2da2" class="">return</span> <span style="color: #4f8187" class="">Angle</span>(value: <span style="color: #272ad8" class="">0.75</span>, unit: .<span style="color: #703daa" class="">revolutions</span>)</div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; }</div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 12px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135); background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">let</span><span style="color: #000000" class=""> x = </span>Angle<span style="color: #000000" class="">.</span>threeQuarterTurn</div></div><div class=""><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135); background-color: rgb(255, 255, 255);" class="">x<span style="color: #000000" class="">.</span>sine<span style="color: #000000" class=""> </span><span style="color: #008400" class="">// -1</span></div></div></blockquote><div class=""><div><br class=""></div><div>-BJ</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 13, 2018, at 9:31 PM, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I would like to see a full Geometry implementation but I don't think it should be part of the standard library.<div class=""><br class=""></div><div class="">I've kicked around some ideas here:&nbsp;</div><div class=""><br class=""></div><div class="">*&nbsp;<a href="https://gist.github.com/erica/8cb4b21cf0c429828fad1d8ad459b71b" class="">https://gist.github.com/erica/8cb4b21cf0c429828fad1d8ad459b71b</a></div><div class="">*&nbsp;<a href="https://gist.github.com/erica/ee06008202c9fed699bfa6254c42c721" class="">https://gist.github.com/erica/ee06008202c9fed699bfa6254c42c721</a></div><div class=""><br class=""></div><div class="">and</div><div class=""><br class=""></div><div class="">*&nbsp;<a href="https://github.com/erica/SwiftGeometry" class="">https://github.com/erica/SwiftGeometry</a><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Jan 13, 2018, at 7:49 PM, Jonathan Hull via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Evolution,<div class=""><br class=""></div><div class="">I would <i class="">really</i> like to see Swift gain an Angle type in the standard library. &nbsp;Every time I have to deal with an angle in an api, I have to go figure out the conventions for that call. &nbsp;Is it in degrees? Is it in radians? &nbsp;What if it is in radians, but I want to think about it in degrees?</div><div class=""><br class=""></div><div class="">I ended up writing an Angle type for my own code a few years back, and I have to say it is really wonderful. &nbsp;It has greatly simplified my graphics work. &nbsp;It takes a lot of mental load off of my brain when dealing with Angles.</div><div class=""><br class=""></div><div class="">I can of course initialize it either as degrees or radians (or revolutions), but I can also just say things like ‘.threeQuarterTurn’, and then I can get the value back out in whatever format I like. &nbsp;There are also useful additions that let me normalize the angle to different ranges and which let me snap to the nearest multiple of an angle. Both of these are enormously useful for user facing features. &nbsp;I can also do math on angles in a way that makes geometric sense for angles. &nbsp;It is also really useful for interacting with CGVectors in intelligent ways.</div><div class=""><br class=""></div><div class="">Using Doubles or CGFloats to represent angles everywhere is just semantically wrong IMHO, and it stops us from adding all of these angle-specific niceties.</div><div class=""><br class=""></div><div class="">Happy to provide code if there is interest…</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Jon</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>