MathGroup Archive 2000

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

Search the Archive

winding number

  • To: mathgroup at
  • Subject: [mg25345] winding number
  • From: Will Self <wself at>
  • Date: Sat, 23 Sep 2000 03:36:11 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

There has been some discussion of finding out whether a point in the
plane is enclosed in a given polygon.  Here is some code that will
calculate the winding number of a polygonal closed curve about a given
point.  The curve should be given as a list of vertices (the first
vertex does not have to be repeated at the end of the list).  The list
of vertices is called vList in the code.  This is really from Cauchy's
theorem with the integration along segments already done.

Will Self


windingNumber[point_, vList_] := Module[
{g, angle},
g[t_] := Mod[t + Pi, 2Pi] - Pi;
angle[p_, a1_, a2_] := g[ArcTan @@ (a2 - p) - ArcTan @@ (a1 - p)];
(Plus @@ MapThread [ angle[point, #1, #2] & , {vList, RotateLeft[vList]}

Sent via
Before you buy.

  • Prev by Date: Re: Point inside a plygon?
  • Next by Date: Differential operators, Help
  • Previous by thread: Re: just doesn't work
  • Next by thread: Re: winding number