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 ConicalSurface: public ParametricSurface {
0008 public:
0009 ConicalSurface(): m_Concave(true), m_R0(0.0), m_R1(0.0), m_Dz(0.0), m_Alfa(0.0), m_Rc(0.0), m_Slope(0.0) {};
0010 ConicalSurface(const TVector3 &x0, const TVector3 &nz, double r0, double r1, double dz,
0011 double vmin = 0.0, double vmax = 2*M_PI):
0012 ParametricSurface(x0, -dz/2, dz/2, vmin, vmax), m_Concave(true), m_Nz(nz.Unit()), m_R0(r0), m_R1(r1), m_Dz(dz) {
0013 if (!m_Nz.x() && !m_Nz.y()) {
0014 m_Alfa = 0.0;
0015 m_Nr = TVector3(0,0,1);
0016 } else {
0017 auto axis = TVector3(0,0,1).Cross(m_Nz);
0018 m_Alfa = axis.Mag();
0019 m_Nr = axis.Unit();
0020 }
0021
0022 m_Rc = (r0+r1)/2;
0023
0024 m_Slope = (r1-r0)/dz;
0025 };
0026 ~ConicalSurface() {};
0027
0028
0029 TVector3 GetSpacePoint(double z, double phi) const {
0030 TVector3 nn(cos(phi), sin(phi), 0.0);
0031 double r = m_Rc + z*m_Slope;
0032 auto local = z*m_Nz + r*nn;
0033
0034 local.Rotate(m_Alfa, m_Nr);
0035 return GetCenter() + local;
0036 };
0037
0038 TVector3 GetNormal(const TVector3 &xx) const {
0039
0040 auto dx = xx - GetCenter(), axis = dx.Cross(m_Nz).Unit();
0041 dx -= dx.Dot(m_Nz)*m_Nz;
0042 dx.Rotate(-atan(m_Slope), axis);
0043
0044 return (m_Concave ? -1.0 : 1.0)*dx.Unit();
0045 };
0046
0047 bool GetCrossing(const TVector3 &x0, const TVector3 &n0, TVector3 *crs, bool check_normal = true) const;
0048 double GetDistance(const TVector3 &xx) const;
0049
0050 void SetConvex( void ) { m_Concave = false; };
0051 ParametricSurface *_Clone(double angle, const TVector3 &axis) const {
0052 auto copy = new ConicalSurface(*this);
0053
0054 copy->m_Center.Rotate(angle, axis);
0055
0056 copy->m_Nz.Rotate(angle, axis);
0057 copy->m_Nr.Rotate(angle, axis);
0058
0059 return copy;
0060 };
0061
0062
0063 double GetU(const TVector3 &xx) const {
0064 auto dx = xx - GetCenter();
0065
0066 dx.Rotate(-m_Alfa, m_Nr);
0067
0068
0069 return dx.Phi();
0070 };
0071 double GetV(const TVector3 &xx) const {
0072 return (xx - GetCenter()).Dot(m_Nz);
0073 };
0074
0075 private:
0076 bool m_Concave;
0077 TVector3 m_Nz, m_Nr;
0078 double m_R0, m_R1, m_Dz, m_Alfa, m_Rc, m_Slope;
0079
0080 #ifndef DISABLE_ROOT_IO
0081 ClassDef(ConicalSurface, 1);
0082 #endif
0083 };
0084
0085 }