Re: Sorting complex points
- To: mathgroup at smc.vnet.net
- Subject: [mg55909] Re: Sorting complex points
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sat, 9 Apr 2005 03:56:35 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 4/8/05 at 1:37 AM, montoz at iol.it (OT) wrote: >I'm trying to sort lists of random complex points on the unit >circle using their angles as criterion to sort them: I mean, if >z=Cos[a]+I*Sin[a] and w=Cos[b]+I*Sin[b]( 0<=a,b<2*Pi ), I want z<w >if a<b; >how can i do that? Use Arg with Sort, i.e. First generate some random points on the circle data = {#,Sqrt[1-#^2]}&/@Table[Random[],{5}]; Then sort the data as follows: s=Sort[data, OrderedQ at {Arg[#1.{1,I}],Arg[#2.{1,I}]}&] and finally after loading Graphics` <<Graphics DisplayTogether[ LabeledListPlot[MapIndexed[Join, s], Axes -> None], ParametricPlot[{Cos[x], Sin[x]}, {x, 0, 2*Pi}], PlotRange -> {{-1.1, 1.1}, {-1.1, 1.1}}, AspectRatio -> 1]; results in a nice display showing the points are sorted by angle and lie on a unit circle -- To reply via email subtract one hundred and four