TGLLine3 rotation

Hi,

suppose I have two 3D points:

        TGLVertex3 A(1, 1, 0.5);
        TGLVertex3 B(1, 1, 0.2);

, which form a line:

        TGLLine3 lineBeforeRotation(A, B);

Now, at point B I want to rotate the line, basically calculating a new point C, knowing both angles theta1 (in the XZ plane) with respect to the old theta0 of the lineBeforeRotation and phi1 (in the XY plane) with respect to the old phi0 of the lineBeforeRotation. I also know the distance between B and C, rho.

What is the simplest way of calculating the cartesian coordinates of the C point?


ROOT Version: 6.14.04
Platform: x86_64-slc6
Compiler: gcc62


I seem to have it figured out by myself:

        TGLVertex3 A(1, 1, 0.5);
        TGLVertex3 B(1, 1, 0.2);
        TGLLine3 lineBeforeRotation(A, B);
        TVector3 vectorBeforeRotation(lineBeforeRotation.Vector().X(), lineBeforeRotation.Vector().Y(), lineBeforeRotation.Vector().Z());
        float theta1 = 45*TMath::DegToRad(); // rotate by this angle wrt old theta
        float phi1 = 45*TMath::DegToRad(); // rotate by this angle wrt old phi
        float rho = 20.;
        TVector3 vectorAfterRotation(vectorBeforeRotation);
        vectorAfterRotation.SetTheta(vectorBeforeRotation.Theta()+theta1);
        vectorAfterRotation.SetPhi(vectorBeforeRotation.Phi()+phi1);
        vectorAfterRotation.SetMag(rho);
        TGLLine3 trackAfterRotation(B, TGLVector3(vectorAfterRotation.X(), vectorAfterRotation.Y(), vectorAfterRotation.Z()));
        printf("C-point coordinates: (%+.2f, %+.2f, %+.2f)\n", trackAfterRotation.End().X(), trackAfterRotation.End().Y(), trackAfterRotation.End().Z());

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.