File indexing completed on 2025-12-10 10:18:06
0001 #pragma once
0002
0003
0004
0005
0006
0007 #include "ParametricSurface.h"
0008
0009 namespace IRT2 {
0010
0011 class CylindricalSurface: public ParametricSurface {
0012 public:
0013 CylindricalSurface(): m_Concave(true), m_Radius(0.0), m_Alfa(0.0) {};
0014 CylindricalSurface(const TVector3 &x0, const TVector3 &nz, double r0, double dz,
0015 double vmin = 0.0, double vmax = 2*M_PI):
0016 ParametricSurface(x0, -dz/2, dz/2, vmin, vmax), m_Concave(true), m_Nz(nz.Unit()), m_Radius(r0) {
0017 if (!m_Nz.x() && !m_Nz.y()) {
0018 m_Alfa = 0.0;
0019 m_Nr = TVector3(0,0,1);
0020 } else {
0021 auto axis = TVector3(0,0,1).Cross(m_Nz);
0022 m_Alfa = axis.Mag();
0023 m_Nr = axis.Unit();
0024 }
0025 };
0026 ~CylindricalSurface() {};
0027
0028
0029 TVector3 GetSpacePoint(double z, double phi) const {
0030 TVector3 nn(cos(phi), sin(phi), 0.0);
0031 auto local = z*m_Nz + m_Radius*nn;
0032
0033 local.Rotate(m_Alfa, m_Nr);
0034
0035 return GetCenter() + local;
0036 };
0037
0038 TVector3 GetNormal(const TVector3 &xx) const {
0039 auto dx = xx - GetCenter();
0040 dx -= dx.Dot(m_Nz)*m_Nz;
0041
0042 return (m_Concave ? -1.0 : 1.0)*dx.Unit();
0043 };
0044
0045 bool GetCrossing(const TVector3 &x0, const TVector3 &n0, TVector3 *crs, bool check_normal = true) const;
0046 double GetDistance(const TVector3 &xx) const;
0047
0048 void SetConvex( void ) { m_Concave = false; };
0049 ParametricSurface *_Clone(double angle, const TVector3 &axis) const {
0050 auto copy = new CylindricalSurface(*this);
0051
0052 copy->m_Center.Rotate(angle, axis);
0053
0054 copy->m_Nz.Rotate(angle, axis);
0055 copy->m_Nr.Rotate(angle, axis);
0056
0057 return copy;
0058 };
0059
0060 double GetU(const TVector3 &xx) const {
0061 auto dx = xx - GetCenter();
0062
0063 dx.Rotate(-m_Alfa, m_Nr);
0064
0065 return dx.Phi();
0066 };
0067 double GetV(const TVector3 &xx) const {
0068 return (xx - GetCenter()).Dot(m_Nz);
0069 };
0070
0071 private:
0072 bool m_Concave;
0073 TVector3 m_Nz, m_Nr;
0074 double m_Radius, m_Alfa;
0075
0076 #ifndef DISABLE_ROOT_IO
0077 ClassDef(CylindricalSurface, 1);
0078 #endif
0079 };
0080
0081 }