LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
voronoi2d::EventUtilities Class Reference

Internal class definitions to facilitate construction of diagram. More...

#include "EventUtilities.h"

Public Member Functions

 EventUtilities ()
 
 ~EventUtilities ()
 
double computeArcVal (const double, const double, const IEvent *) const
 
double computeBreak (const double, const IEvent *, const IEvent *, RootsPair &) const
 
bool newSiteToLeft (const IEvent *, const IEvent *, const IEvent *) const
 

Detailed Description

Internal class definitions to facilitate construction of diagram.

Definition at line 28 of file EventUtilities.h.

Constructor & Destructor Documentation

voronoi2d::EventUtilities::EventUtilities ( )
inline

Definition at line 31 of file EventUtilities.h.

31 {}
voronoi2d::EventUtilities::~EventUtilities ( )
inline

Definition at line 32 of file EventUtilities.h.

References computeArcVal(), computeBreak(), and newSiteToLeft().

32 {}

Member Function Documentation

double voronoi2d::EventUtilities::computeArcVal ( const double  beachPos,
const double  yPos,
const IEvent arc 
) const

Definition at line 26 of file EventUtilitiies.cxx.

References max, voronoi2d::IEvent::xPos(), and voronoi2d::IEvent::yPos().

Referenced by voronoi2d::VoronoiDiagram::terminateInfiniteEdges(), and ~EventUtilities().

27 {
28  // Note that if the input arc site point lies on the beach line then the arc position is infinite
29  double arcVal = std::numeric_limits<double>::max();
30  double deltaxLx = arc->xPos() - beachPos;
31 
32  if (std::abs(deltaxLx) > std::numeric_limits<double>::epsilon())
33  {
34  double deltayPy = yPos - arc->yPos();
35  double sumPxLx = arc->xPos() + beachPos;
36 
37  arcVal = 0.5 * (deltayPy * deltayPy / deltaxLx + sumPxLx);
38  }
39 
40  return arcVal;
41 }
Int_t max
Definition: plot.C:27
double voronoi2d::EventUtilities::computeBreak ( const double  beachLinePos,
const IEvent leftArc,
const IEvent rightArc,
RootsPair roots 
) const

Definition at line 43 of file EventUtilitiies.cxx.

References max, min, voronoi2d::IEvent::xPos(), and voronoi2d::IEvent::yPos().

Referenced by newSiteToLeft(), voronoi2d::VoronoiDiagram::terminateInfiniteEdges(), and ~EventUtilities().

44 {
45  // Given arcs to the left and right of this node (meaning we are a breakpoint), compute the
46  // current coordinates of the breakpoint based on the input beachline position
47  double lx = beachLinePos;
48  double deltaX1 = leftArc->xPos() - lx;
49  double deltaX2 = rightArc->xPos() - lx;
50  double breakPoint = -std::numeric_limits<double>::max();
51 
52  // if the two are the same then the arcs are side-by-side and intersection is right in the middle
53  if (std::abs(deltaX1 - deltaX2) < std::numeric_limits<double>::epsilon()) breakPoint = 0.5 * (rightArc->yPos() + leftArc->yPos());
54 
55  // otherwise, we do the full calculation
56  else
57  {
58  // set up for quadratic equation
59  double p1x = leftArc->xPos();
60  double p1y = leftArc->yPos();
61  double p2x = rightArc->xPos();
62  double p2y = rightArc->yPos();
63  double a = p2x - p1x;
64  double b = 2. * (p2y * deltaX1 - p1y * deltaX2);
65  double c = deltaX2 * (p1y * p1y + deltaX1 * (p1x + lx)) - deltaX1 * (p2y * p2y + deltaX2 * (p2x + lx));
66  double radical = std::max(0.,b * b - 4. * a * c);
67 
68  if (radical > 0.) radical = sqrt(radical);
69 
70  double rootPos = 0.5 * (-b + radical) / a;
71  double rootNeg = 0.5 * (-b - radical) / a;
72 
73  roots.first = std::min(rootPos, rootNeg);
74  roots.second = std::max(rootPos, rootNeg);
75 
76  // Ah yes, the eternal question... which solution?
77  // Generally, we think we want the solution which is "between" the left and the right
78  // However, it can be that the right arc is the remnant of an arc whose center lies to the
79  // left of the center of the left arc, and vice versa.
80  if (p1x < p2x) breakPoint = roots.second;
81  else breakPoint = roots.first;
82  }
83 
84  return breakPoint;
85 }
Int_t max
Definition: plot.C:27
Int_t min
Definition: plot.C:26
bool voronoi2d::EventUtilities::newSiteToLeft ( const IEvent newSite,
const IEvent leftArc,
const IEvent rightArc 
) const

Definition at line 87 of file EventUtilitiies.cxx.

References computeBreak(), voronoi2d::IEvent::xPos(), and voronoi2d::IEvent::yPos().

Referenced by ~EventUtilities().

88 {
89  // Note that the input site is used to give us the position of the sweep line
90  // Using the coordinates of the beach line then recover the current breakpoint between the two
91  // input arcs
92  RootsPair roots;
93 
94  double breakPoint = computeBreak(newSite->xPos()-0.000001, leftArc, rightArc, roots);
95 
96  return newSite->yPos() < breakPoint;
97 }
double computeBreak(const double, const IEvent *, const IEvent *, RootsPair &) const
std::pair< double, double > RootsPair

The documentation for this class was generated from the following files: