commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Nozik <>
Subject [math] Rotation around given direction
Date Mon, 08 Jul 2013 12:44:29 GMT
  In order to solve some Monte-Carlo problem I need to implement the 
following procedure: during interaction I know the difference between 
the initial and the final angle "dTheta" (the direction is random) and 
the initial polar angle "theta" (using notation like here 
What i need to know is the final polar angle. Azimuthal angle does not 
In order to do so I am creating two vectors with polar angles "theta" 
and "theta + dTheta" and trying to rotate one around the other for a 
random angle "phi" (phi could be fixed as well, it does not matter). 
What i don't understand is why the angle between the final vector and 
the initial one is not "dTheta"?

I use the following code:

    double addTheta(double theta, double dTheta) {
         double phi = * 2 * Math.PI;
         SphericalCoordinates init = new SphericalCoordinates(1, 0, 
         SphericalCoordinates rotate = new SphericalCoordinates(1, 0, 
         Rotation rot = new Rotation(rotate.getCartesian(), phi);

         Vector3D result = rot.applyTo(init.getCartesian());

         assert Vector3D.angle(result, init.getCartesian()) == dTheta;
         return Math.acos(result.getZ());


Thanks in advance.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message