CMS 3D CMS Logo

FourPointPlaneBounds.cc
Go to the documentation of this file.
1 // #include "Utilities/Configuration/interface/Architecture.h"
2 
5 #include <algorithm>
6 #include <iostream>
7 
9  const LocalPoint& b,
10  const LocalPoint& c,
11  const LocalPoint& d) {
12  corners_[0] = Local2DPoint(a.x(), a.y());
13  corners_[1] = Local2DPoint(b.x(), b.y());
14  corners_[2] = Local2DPoint(c.x(), c.y());
15  corners_[3] = Local2DPoint(d.x(), d.y());
16 
17  // check for convexity
18  for (int i = 0; i < 4; ++i) {
19  if (checkSide(i, corner(i + 2)) * checkSide(i, corner(i + 3)) < 0) { // not on same side
20  throw GeometryError("FourPointPlaneBounds: coners not in order or not convex");
21  }
22  }
23 
24  double side = checkSide(0, corners_[2]); // - for clockwise corners, + for counterclockwise
25  if (side < 0) {
26  std::cout << "FourPointPlaneBounds: Changing order of corners to counterclockwise" << std::endl;
27  std::swap(corners_[1], corners_[3]);
28  }
29 }
30 
31 double FourPointPlaneBounds::checkSide(int i, const Local2DPoint& lp) const { return checkSide(i, lp.x(), lp.y()); }
32 
34  for (int i = 0; i < 4; ++i) {
35  if (checkSide(i, lp.x(), lp.y()) < 0)
36  return false;
37  }
38  return true;
39 }
40 
41 float FourPointPlaneBounds::length() const { return 0; }
42 float FourPointPlaneBounds::width() const { return 0; }
43 float FourPointPlaneBounds::thickness() const { return 0; }
Point2DBase< float, LocalTag >
mps_fire.i
i
Definition: mps_fire.py:428
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
gather_cfg.cout
cout
Definition: gather_cfg.py:144
FourPointPlaneBounds::width
float width() const override
Definition: FourPointPlaneBounds.cc:42
FourPointPlaneBounds::inside
bool inside(const Local3DPoint &lp) const override
Determine if the point is inside the bounds.
Definition: FourPointPlaneBounds.cc:33
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
FourPointPlaneBounds::thickness
float thickness() const override
Definition: FourPointPlaneBounds.cc:43
Point3DBase< float, LocalTag >
b
double b
Definition: hdecay.h:118
GeomExceptions.h
a
double a
Definition: hdecay.h:119
FourPointPlaneBounds::FourPointPlaneBounds
FourPointPlaneBounds(const LocalPoint &a, const LocalPoint &b, const LocalPoint &c, const LocalPoint &d)
Definition: FourPointPlaneBounds.cc:8
PV2DBase::y
T y() const
Definition: PV2DBase.h:44
PV2DBase::x
T x() const
Definition: PV2DBase.h:43
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
FourPointPlaneBounds::corner
const Local2DPoint & corner(int i) const
Definition: FourPointPlaneBounds.h:33
FourPointPlaneBounds::corners_
Local2DPoint corners_[4]
Definition: FourPointPlaneBounds.h:31
GeometryError
Definition: GeomExceptions.h:18
FourPointPlaneBounds::length
float length() const override
Definition: FourPointPlaneBounds.cc:41
FourPointPlaneBounds.h
ztail.d
d
Definition: ztail.py:151
FourPointPlaneBounds::checkSide
double checkSide(int i, const Local2DPoint &lp) const
Definition: FourPointPlaneBounds.cc:31
Local2DPoint
Point2DBase< float, LocalTag > Local2DPoint
Definition: LocalPoint.h:8
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46