MathGroup Archive 1997

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

Search the Archive

Parsing polygons: A good solution

  • To: mathgroup at
  • Subject: [mg9072] Parsing polygons: A good solution
  • From: Russell Towle <rustybel at>
  • Date: Thu, 9 Oct 1997 01:42:51 -0400
  • Sender: owner-wri-mathgroup at

Hi all,

With respect to the problem I posed concerning removing from a list, those
polygons which fall into coincidence in pairs in 3-space, Xah Lee provided
an excellent solution, although I have yet to understand in detail how it
works. His solution and my much slower one depend upon a function,
"facent," which returns the centroid of a polygon.

Here it is, applied to a list of polygons named "trip1":

	(DeleteCases[#,Null,{1}]&) @ (Flatten[#,1]&) @
	((If[SameQ@@(Head/@#),Null,#]&) /@
	Sort[((Chop[Rationalize[(facent at #),10^-2]])@#&/@ (trip1)),
		OrderedQ[{Head at #1,Head at #2}]&],

Xah's method is about 8 times faster than my previous fastest method, below:

centfaces=Map[Rationalize[facent[#],10^-3]&, trip1];
Position[ Map[g==#&,centfaces],x_ /; x==True],
red=Flatten[ Select[h ,Length[#]==1&]];

Russell Towle
Giant Gap Press:  books on California history, digital topographic maps
P.O. Box 141
Dutch Flat, California 95714
Voice:  (916) 389-2872
e-mail:  rustybel at

  • Prev by Date: RE: TraceInternal and
  • Next by Date: Re: weird Log[0] *0 result
  • Previous by thread: RE: TraceInternal and
  • Next by thread: Re: weird Log[0] *0 result