83 Fatal(
"Ctor",
"Invalid number of vertices %i", nvert);
118 for (ic=0; ic<
fNvert; ic++) {
120 j =
fInd[(ic+1)%fNvert];
121 area += 0.5*(
fX[i]*
fY[j]-
fX[j]*
fY[i]);
137 for (i=0; i<nd; i++) {
159 point[1] =
fY[fInd[k]];
197 Int_t indnext, indback;
202 if (nskip<0) nskip+=
fNvert;
212 indback = fIndc[indnext]-1;
213 if (indback < 0) indback+=
fNvert;
214 while (indback != fIndc[indconv]) {
217 if (indback < 0) indback+=
fNvert;
242 y[ic] =
fY[fIndc[ic]];
252 (point[1]-
fY[ind1])*(
fX[ind2]-
fX[ind1]);
254 if (dot<-1.
E-10)
return kFALSE;
263 if (i2<0) i2=(i1+1)%
fNvert;
266 if (i==i1 || i==i2)
continue;
268 point[1] =
fY[fInd[i]];
286 if (i==0 && j==(fNvert-1))
continue;
293 x4 =
fX[(j+1)%fNvert];
294 y4 =
fY[(j+1)%fNvert];
296 Error(
"IsIllegalCheck",
"Illegal crossing of segment %d vs. segment %d", i,j);
317 if (iseg+2 >
fNvert)
break;
340 if (ivnew<iseg)
break;
345 Fatal(
"OutscribedConvex",
"cannot build outscribed convex");
360 Double_t lsq, ssq, dx, dy, dpx, dpy, u;
363 for (i1=0; i1<
fNvert; i1++) {
376 dpx = point[0] - p1[0];
377 dpy = point[1] - p1[1];
381 ssq = dpx*dpx + dpy*dpy;
388 u = (dpx*dx + dpy*dy)/lsq;
390 dpx = point[0]-p2[0];
391 dpy = point[1]-p2[1];
398 ssq = dpx*dpx + dpy*dpy;
422 Error(
"SetNextIndex",
"all indices already set");
427 if (!
fX || !
fY)
return;
451 for (i=0; i<nd; i++) {
453 if (poly) poly->
SetXY(x,y);
virtual void Draw(Option_t *option="")
Draw the polygon.
void SetNextIndex(Int_t index=-1)
Sets the next polygone index.
virtual void Delete(Option_t *option="")
Remove all objects from the array AND delete all heap based objects.
void ConvexCheck()
Check polygon convexity.
Bool_t Contains(const Double_t *point) const
Check if a point given by X = point[0], Y = point[1] is inside the polygon.
Double_t Safety(const Double_t *point, Int_t &isegment) const
Compute minimum distance from POINT to any segment. Returns segment index.
An arbitrary polygon defined by vertices.
void GetConvexVertices(Double_t *x, Double_t *y) const
Fill list of vertices of the convex outscribed polygon into provided arrays.
void GetVertices(Double_t *x, Double_t *y) const
Fill list of vertices into provided arrays.
TGeoPolygon()
Dummy constructor.
TObject * At(Int_t idx) const
static Bool_t IsSameWithinTolerance(Double_t a, Double_t b)
Check if two numbers differ with less than a tolerance.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
static const double x2[5]
Bool_t IsIllegalCheck() const
Check for illegal crossings between non-consecutive segments.
static double p2(double t, double a, double b, double c)
static const double x4[22]
Bool_t IsSegConvex(Int_t i1, Int_t i2=-1) const
Check if a segment [0..fNvert-1] belongs to the outscribed convex pgon.
static Bool_t IsSegCrossing(Double_t x1, Double_t y1, Double_t x2, Double_t y2, Double_t x3, Double_t y3, Double_t x4, Double_t y4)
Check if segments (A,B) and (C,D) are crossing, where: A(x1,y1), B(x2,y2), C(x3,y3), D(x4,y4)
void SetXY(Double_t *x, Double_t *y)
Set X/Y array pointer for the polygon and daughters.
Int_t GetEntriesFast() const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
static double p1(double t, double a, double b)
void SetConvex(Bool_t flag=kTRUE)
void OutscribedConvex()
Compute indices for the outscribed convex polygon.
TObject * UncheckedAt(Int_t i) const
static const double x1[5]
Bool_t IsRightSided(const Double_t *point, Int_t ind1, Int_t ind2) const
Check if POINT is right-sided with respect to the segment defined by IND1 and IND2.
R__EXTERN TGeoManager * gGeoManager
Double_t * fY
pointer to list of current X coordinates of vertices
void FinishPolygon()
Decompose polygon in a convex outscribed part and a list of daughter polygons that have to be subtrac...
Bool_t IsClockwise() const
virtual void DrawPolygon(const TGeoPolygon *poly)=0
TObjArray * fDaughters
pointer to list of current Y coordinates of vertices
Double_t Sqrt(Double_t x)
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Double_t Area() const
Computes area of the polygon in [length^2].
virtual ~TGeoPolygon()
Destructor.
TVirtualGeoPainter * GetGeomPainter()
Make a default painter if none present. Returns pointer to it.
static const double x3[11]