MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Sorting complex points

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55882] Re: Sorting complex points
  • From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
  • Date: Sat, 9 Apr 2005 03:55:17 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <d356km$ovn$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

data = Table[phi = Random[Real, {0, 2Pi}]; 
Cos[phi] + I*Sin[phi], {10}];

indexPos[z_, {i_}] := Module[{x = Re[z], y = 
Im[z]},
{Point[{x, y}], Text[i, {x, y}, {-1, -1}]}]

Show[Graphics[
MapIndexed[indexPos, data], AspectRatio -> 
Automatic]]

and now sort the points

sorted = Sort[data, Arg[#1] < Arg[#2] &];

Show[Graphics[
MapIndexed[indexPos, sorted], AspectRatio -> 
Automatic]]

Regards

  Jens

"OT" <montoz at iol.it> schrieb im Newsbeitrag 
news:d356km$ovn$1 at smc.vnet.net...
> Hi all,
>
> 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?
>
> I tried to define Angle[z] as a piecewise 
> funztion, but I still don't
> understand how to use it with Sort...
>
> Thanks,
>
> andrea
> 



  • Prev by Date: Re: Recommendations for a programming book?
  • Next by Date: Re: Sorting complex points
  • Previous by thread: Re: Sorting complex points
  • Next by thread: Re: Sorting complex points