LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
voronoi2d::EventUtilities Class Reference

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

#include "EventUtilities.h"

Public Member Functions

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 26 of file EventUtilities.h.

Member Function Documentation

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

Definition at line 22 of file EventUtilities.cxx.

References util::abs(), voronoi2d::IEvent::xPos(), and voronoi2d::IEvent::yPos().

Referenced by voronoi2d::VoronoiDiagram::terminateInfiniteEdges().

23  {
24  // Note that if the input arc site point lies on the beach line then the arc position is infinite
25  double arcVal = std::numeric_limits<double>::max();
26  double deltaxLx = arc->xPos() - beachPos;
27 
28  if (std::abs(deltaxLx) > std::numeric_limits<double>::epsilon()) {
29  double deltayPy = yPos - arc->yPos();
30  double sumPxLx = arc->xPos() + beachPos;
31 
32  arcVal = 0.5 * (deltayPy * deltayPy / deltaxLx + sumPxLx);
33  }
34 
35  return arcVal;
36  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
double voronoi2d::EventUtilities::computeBreak ( const double  beachLinePos,
const IEvent leftArc,
const IEvent rightArc,
RootsPair roots 
) const

Definition at line 38 of file EventUtilities.cxx.

References util::abs(), voronoi2d::IEvent::xPos(), and voronoi2d::IEvent::yPos().

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

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

Definition at line 88 of file EventUtilities.cxx.

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

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

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