Skip to content

Commit

Permalink
fix: Fix issue with applying transformation to bevelled cylinders (#1185
Browse files Browse the repository at this point in the history
)

Applying transforms to the cylinder did not work as intended. These fixes should place the side disks at the right place as well as fixing the visualization of the cylinder length.
  • Loading branch information
noraemi committed Mar 15, 2022
1 parent 1c1b624 commit b804b32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 2 additions & 6 deletions Core/src/Geometry/CylinderVolumeBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,15 @@ Acts::OrientedSurfaces Acts::CylinderVolumeBounds::orientedSurfaces(
double bevelMaxZ = get(eBevelMaxZ);
Transform3 transMinZ, transMaxZ;
if (bevelMinZ != 0.) {
double rmax = get(eMaxR);
double rmin = get(eMinR);
double sy = (rmax + rmin) * (1 - std::cos(bevelMinZ)) / std::cos(bevelMinZ);
double sy = 1 - 1 / std::cos(bevelMinZ);
transMinZ = transform * vMinZ *
Eigen::AngleAxisd(-bevelMinZ, Eigen::Vector3d(1., 0., 0.)) *
Eigen::Scaling(1., 1. + sy, 1.);
} else {
transMinZ = transform * vMinZ;
}
if (bevelMaxZ != 0.) {
double rmax = get(eMaxR);
double rmin = get(eMinR);
double sy = (rmax + rmin) * (1 - std::cos(bevelMaxZ)) / std::cos(bevelMaxZ);
double sy = 1 - 1 / std::cos(bevelMaxZ);
transMaxZ = transform * vMaxZ *
Eigen::AngleAxisd(bevelMaxZ, Eigen::Vector3d(1., 0., 0.)) *
Eigen::Scaling(1., 1. + sy, 1.);
Expand Down
7 changes: 6 additions & 1 deletion Core/src/Surfaces/CylinderBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,12 @@ std::vector<Acts::Vector3> Acts::CylinderBounds::createCircles(
if ((bevelMinZ != 0. || bevelMaxZ != 0.) && vertices.size() % 2 == 0) {
auto halfWay = vertices.end() - vertices.size() / 2;
double mult{1};
auto func = [&mult](Vector3& v) { v(2) += v(1) * mult; };
auto invCtrans = ctrans.inverse();
auto func = [&mult, &ctrans, &invCtrans](Vector3& v) {
v = invCtrans * v;
v(2) += v(1) * mult;
v = ctrans * v;
};
if (bevelMinZ != 0.) {
mult = std::tan(-bevelMinZ);
std::for_each(vertices.begin(), halfWay, func);
Expand Down

0 comments on commit b804b32

Please sign in to comment.