Commit f7c29d0d authored by Håkan Wennlöf's avatar Håkan Wennlöf
Browse files

Merge branch 'b-implantoffset' into 'v3.0-stable'

[v3.0-stable] Translation and rotation correction in intercept

See merge request allpix-squared/allpix-squared!1044
parents 0ed31404 f2799eaf
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -326,7 +326,12 @@ std::optional<ROOT::Math::XYZPoint> DetectorModel::Implant::intersect(const ROOT
    // Shift position to implant coordinate system and apply rotation around z axis!
    if(shape_ == Implant::Shape::RECTANGLE) {
        // Use Liang-Barsky line clipping method:
        return LiangBarsky::closestIntersection(orientation_(direction), orientation_(position - offset_), size_);
        auto intercept = LiangBarsky::closestIntersection(orientation_(direction), orientation_(position - offset_), size_);
        if(intercept.has_value()) {
            // Translate back into local coordinates of the sensor:
            intercept = orientation_.Inverse()(intercept.value()) + offset_;
        }
        return intercept;
    } else if(shape_ == Implant::Shape::ELLIPSE) {
        // Translate so the ellipse is centered at the origin.
        auto pos = orientation_(position - offset_);