Import Geant4 10.4.0 source tree
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ExtrudedSolid.icc 66356 2012-12-18 09:02:32Z gcosmo $
|
||||
// $Id: G4ExtrudedSolid.icc 107111 2017-11-02 14:33:38Z gcosmo $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 inline definitions file
|
||||
@@ -80,3 +80,50 @@ std::vector<G4ExtrudedSolid::ZSection> G4ExtrudedSolid::GetZSections() const
|
||||
{
|
||||
return fZSections;
|
||||
}
|
||||
|
||||
inline
|
||||
G4bool G4ExtrudedSolid::PointInPolygon(const G4ThreeVector& p) const
|
||||
{
|
||||
G4bool in = 0;
|
||||
G4int icur = (fPolygon[fNv-1].y() > p.y()), iprev = 0;
|
||||
for (G4int i = 0; i < fNv; i++)
|
||||
{
|
||||
iprev = icur;
|
||||
if ((icur = (fPolygon[i].y() > p.y())) != iprev)
|
||||
{
|
||||
in ^= (p.y()*fLines[i].k + fLines[i].m < p.x());
|
||||
}
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
inline
|
||||
G4double G4ExtrudedSolid::DistanceToPolygonSqr(const G4ThreeVector& p) const
|
||||
{
|
||||
G4double dd = DBL_MAX;
|
||||
for (G4int i=0, k=fNv-1; i<fNv; k=i++)
|
||||
{
|
||||
G4double ix = p.x() - fPolygon[i].x();
|
||||
G4double iy = p.y() - fPolygon[i].y();
|
||||
G4double u = fPlanes[i].a*iy - fPlanes[i].b*ix;
|
||||
if (u < 0)
|
||||
{
|
||||
G4double tmp = ix*ix + iy*iy;
|
||||
if (tmp < dd) dd = tmp;
|
||||
}
|
||||
else if (u > fLengths[i])
|
||||
{
|
||||
G4double kx = p.x() - fPolygon[k].x();
|
||||
G4double ky = p.y() - fPolygon[k].y();
|
||||
G4double tmp = kx*kx + ky*ky;
|
||||
if (tmp < dd) dd = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4double tmp = fPlanes[i].a*p.x() + fPlanes[i].b*p.y() + fPlanes[i].d;
|
||||
tmp *= tmp;
|
||||
if (tmp < dd) dd = tmp;
|
||||
}
|
||||
}
|
||||
return dd;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user