9 inline Vector2D DiscSurface::localPolarToCartesian(
15 inline Vector2D DiscSurface::localCartesianToPolar(
33 const double x = direction(0);
34 const double y = direction(1);
35 const double z = direction(2);
38 const double cos_theta =
z;
39 const double sin_theta = sqrt(x * x + y * y);
40 const double inv_sin_theta = 1. / sin_theta;
41 const double cos_phi = x * inv_sin_theta;
42 const double sin_phi = y * inv_sin_theta;
44 const auto rframe = referenceFrame(gctx, position, direction);
49 double lcos_phi =
cos(lphi);
50 double lsin_phi = sin(lphi);
53 lcos_phi * rframe.block<3, 1>(0, 0) + lsin_phi * rframe.block<3, 1>(0, 1);
55 lrad * (lcos_phi * rframe.block<3, 1>(0, 1) -
56 lsin_phi * rframe.block<3, 1>(0, 0));
60 jacobian(4,
eBoundPhi) = (-sin_theta) * sin_phi;
62 jacobian(5,
eBoundPhi) = sin_theta * cos_phi;
74 const double x = direction(0);
75 const double y = direction(1);
76 const double z = direction(2);
78 const double cosTheta =
z;
79 const double sinTheta = sqrt(x * x + y * y);
80 const double invSinTheta = 1. / sinTheta;
81 const double cosPhi = x * invSinTheta;
82 const double sinPhi = y * invSinTheta;
85 referenceFrame(gctx, position, direction).transpose();
88 const double lr =
perp(pos_loc);
89 const double lphi =
phi(pos_loc);
90 const double lcphi =
cos(lphi);
91 const double lsphi = sin(lphi);
93 auto lx = rframeT.block<1, 3>(0, 0);
94 auto ly = rframeT.block<1, 3>(1, 0);
95 jacobian.block<1, 3>(0, 0) = lcphi * lx + lsphi * ly;
96 jacobian.block<1, 3>(1, 0) = (lcphi * ly - lsphi * lx) / lr;
100 jacobian(
eBoundPhi, 4) = -sinPhi * invSinTheta;
101 jacobian(
eBoundPhi, 5) = cosPhi * invSinTheta;
112 const Vector3D& direction,
const BoundaryCheck& bcheck)
const {
119 if (intersection.status != Intersection3D::Status::unreachable and bcheck and
120 m_bounds !=
nullptr) {
122 const auto& tMatrix = gctxTransform.matrix();
123 const Vector3D vecLocal(intersection.position - tMatrix.block<3, 1>(0, 3));
125 tMatrix.block<3, 2>(0, 0).transpose() * vecLocal;
126 if (bcheck.type() == BoundaryCheck::Type::eAbsolute and
127 m_bounds->coversFullAzimuth()) {
131 intersection.status = Intersection3D::Status::missed;
133 }
else if (not insideBounds(localCartesianToPolar(lcartesian), bcheck)) {
134 intersection.status = Intersection3D::Status::missed;
137 return {intersection,
this};
141 DiscSurface::localCartesianToBoundLocalDerivative(
146 const auto& sTransform =
transform(gctx);
149 const double lr =
perp(localPos);
150 const double lphi =
phi(localPos);
151 const double lcphi =
std::cos(lphi);
152 const double lsphi = std::sin(lphi);
154 LocalCartesianToBoundLocalMatrix::Zero();
155 loc3DToLocBound << lcphi, lsphi, 0, -lsphi / lr, lcphi / lr, 0;
157 return loc3DToLocBound;
163 const auto& tMatrix =
transform(gctx).matrix();
164 return Vector3D(tMatrix(0, 2), tMatrix(1, 2), tMatrix(2, 2));
169 if (bValue ==
binR) {
170 double r = m_bounds->binningValueR();
171 double phi = m_bounds->binningValuePhi();
172 return Vector3D(r *
cos(phi), r * sin(phi), center(gctx).
z());
177 inline double DiscSurface::binningPositionValue(
const GeometryContext& gctx,
180 if (bValue ==
binR) {
183 return GeometryObject::binningPositionValue(gctx, bValue);
190 return 1. /
std::abs(Surface::normal(gctx, position).dot(direction));