That's certainly tighter, thank you, Alan. Would making the conditional part of the API be useful to others?
Cheers! On Fri, Oct 14, 2022 at 3:42 PM Alan Braslau <alan.bras...@icloud.com> wrote: > > On Fri, 14 Oct 2022 11:59:49 -0700 > Thangalin <thanga...@gmail.com> wrote: > > > I don't think an atantwo is needed. I *thought* I had read somewhere > > that atan( y, x ) was equivalent to calling atan2 in Lua. Ensuring > > there's no breakage when x == y would be nice, though. It was a little > > surprising to see angle return degrees rather than radians, but it > > does simplify my code: > > > > dc := vbc - vac; > > dr := vbr - var; > > vi := 0; > > > > if not( dc == dr ): > > vi := round( angle( dc, dr ) / 60 ); > > fi; > > > > % Compute the direction towards the first segment (to vertex of > > an edge). vangle := vi * 60 * pi / 180; > > > > Even simpler would be: > > > > dc := vbc - vac; > > dr := vbr - var; > > vi := round( angle( dc, dr ) / 60 ); % returns 0 when dc == dr > > > > % Compute the direction towards the first segment (to vertex of > > an edge). vangle := vi * 60 * pi / 180; > > > > Or accepting a third argument as the return value in the special case: > > > > vi := round( angle( dc, dr, 0 ) / 60 ); % returns 0 when dc == > > dr > > > > Cheers! > > vi := if (dc = dr) : 0 else : round (angle(dc,dr)/60) fi ; > > Alan ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___________________________________________________________________________________