1 | #ifndef __PARABOLICSURFACE__ |
---|
2 | #define __PARABOLICSURFACE__ |
---|
3 | |
---|
4 | #include "ParametricSurface.h" |
---|
5 | |
---|
6 | namespace G4FresnelLens{ |
---|
7 | |
---|
8 | class ParabolicSurface : public ParametricSurface |
---|
9 | { |
---|
10 | public: |
---|
11 | ParabolicSurface(double k=DBL_MAX, double z=0., double rhomax=0.); |
---|
12 | ~ParabolicSurface(); |
---|
13 | |
---|
14 | void Configure(); |
---|
15 | double PointOnSurf(double x); |
---|
16 | double PointOnSurf2(double x); |
---|
17 | double DistanceToSurf(const G4ThreeVector& p, const G4ThreeVector& v); |
---|
18 | double DistanceToSurfSafe(const G4ThreeVector& p); |
---|
19 | void FillSegment(double rho, FSIntersectedSegment *intSeg); |
---|
20 | double Derivative(double rho); |
---|
21 | bool Normal(FSIntersectedSegment* ints, const G4ThreeVector& p, double up, G4ThreeVector* norm); |
---|
22 | |
---|
23 | void print(); |
---|
24 | protected: |
---|
25 | void GuessParameters(int n, int tn, int* idx, double* rho, double* z, bool minimum); |
---|
26 | void GuessParameters(const std::vector<SSurface*>& surfaces, bool minimum); |
---|
27 | |
---|
28 | private: |
---|
29 | double fK; |
---|
30 | }; |
---|
31 | |
---|
32 | //__________________________________________________________________________________ |
---|
33 | inline void ParabolicSurface::FillSegment(double rho, FSIntersectedSegment *intSeg){ |
---|
34 | intSeg->surf=this; |
---|
35 | intSeg->perp=rho; |
---|
36 | } |
---|
37 | |
---|
38 | //__________________________________________________________________________________ |
---|
39 | inline double ParabolicSurface::PointOnSurf(double x){ |
---|
40 | return fZpos+fK*x*x; |
---|
41 | } |
---|
42 | |
---|
43 | //__________________________________________________________________________________ |
---|
44 | inline double ParabolicSurface::PointOnSurf2(double x2){ |
---|
45 | return fZpos+fK*x2; |
---|
46 | } |
---|
47 | |
---|
48 | //__________________________________________________________________________________ |
---|
49 | inline double ParabolicSurface::Derivative(double x){ |
---|
50 | return 2.*fK*x; |
---|
51 | } |
---|
52 | |
---|
53 | //______________________________________________________________________________ |
---|
54 | inline bool ParabolicSurface::Normal(FSIntersectedSegment* ints, const G4ThreeVector& p, double out, G4ThreeVector* norm){ |
---|
55 | double perp=p.perp(); |
---|
56 | double tgth=Derivative(perp); |
---|
57 | double c=out/sqrt(1.+tgth*tgth); |
---|
58 | double s=tgth*c; |
---|
59 | double iperp=-1./perp; |
---|
60 | norm->set(p.x()*iperp*s,p.y()*iperp*s,c); |
---|
61 | return true; |
---|
62 | } |
---|
63 | |
---|
64 | }; |
---|
65 | |
---|
66 | #endif |
---|