File indexing completed on 2025-12-10 10:18:06
0001 #pragma once
0002
0003 #include "ParametricSurface.h"
0004
0005 namespace IRT2 {
0006
0007 class SphericalSurface: public ParametricSurface {
0008 public:
0009 SphericalSurface(): m_Concave(true), m_Radius(0.0) {};
0010 SphericalSurface(const TVector3 &x0, double r0, double umin = 0.0, double umax = M_PI,
0011 double vmin = 0.0, double vmax = 2*M_PI):
0012 ParametricSurface(x0, umin, umax, vmin, vmax), m_Concave(true), m_Radius(r0) {};
0013 ~SphericalSurface() {};
0014
0015
0016 TVector3 GetSpacePoint(double theta, double phi) const {
0017 TVector3 nn(sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta));
0018 return GetCenter() + m_Radius*nn;
0019 };
0020
0021 TVector3 GetNormal(const TVector3 &xx) const {
0022 return (m_Concave ? -1.0 : 1.0)*(xx - GetCenter()).Unit();
0023 };
0024 double GetRadius( void ) const { return m_Radius; };
0025
0026 bool GetCrossing(const TVector3 &x0, const TVector3 &n0, TVector3 *crs, bool check_normal = true) const;
0027 double GetDistance(const TVector3 &xx) const;
0028
0029 void SetConvex( void ) { m_Concave = false; };
0030 ParametricSurface *_Clone(double angle, const TVector3 &axis) const {
0031 auto copy = new SphericalSurface(*this);
0032
0033 copy->m_Center.Rotate(angle, axis);
0034
0035 return copy;
0036 };
0037
0038
0039 double GetU(const TVector3 &xx) const { return (xx - GetCenter()).Theta(); };
0040 double GetV(const TVector3 &xx) const { return (xx - GetCenter()).Phi(); };
0041
0042 private:
0043 bool m_Concave;
0044 double m_Radius;
0045
0046 #ifndef DISABLE_ROOT_IO
0047 ClassDef(SphericalSurface, 2);
0048 #endif
0049 };
0050
0051 }