TVector3::Rotate to arbitrary rotation using XYZVector

Thanks @ferhue

testing with

void testRotation() {
    TVector3 at(17, -4, -23);
    XYZVector ag(17, -4, -23);
    double angle = 100;

    std::cout << "at: " << at.X() << ", " << at.Y() << ", " << at.Z() << std::endl;
    std::cout << "ag: " << ag.X() << ", " << ag.Y() << ", " << ag.Z() << std::endl;

    TVector3 axist(-23.4, 1.7, -0.3);
    XYZVector axisg(-23.4, 1.7, -0.3);

    std::cout << "axist: " << axist.X() << ", " << axist.Y() << ", " << axist.Z() << std::endl;
    std::cout << "axisg: " << axisg.X() << ", " << axisg.Y() << ", " << axisg.Z() << std::endl;

    at.Rotate(angle, axist);

    XYZVector rotated = Rotate(ag, angle, axisg);

    std::cout << "Rotated TVector: " << at.X() << ", " << at.Y() << ", " << at.Z() << std::endl;
    std::cout << "Rotated GenVector: " << rotated.X() << ", " << rotated.Y() << ", " << rotated.Z() << std::endl;
}

with several different values for the initial vector, the angle, and the axis I always observe the same result for both the rotated TVector3 as well as the rotated XYZVector (up to the 6th digit).

So yes, that function solves the issue. Thanks a lot!

1 Like