# commons-user mailing list archives

##### Site index · List index
Message view
Top
From Alexander Nozik <alta...@gmail.com>
Subject Re: [math] Rotation around given direction
Date Mon, 08 Jul 2013 16:34:24 GMT
```Hello Luc,
thank you very much for your answer. Of course it is all my
absentmindedness. The code itself is correct but the condition is wrong.
The Monte-Carlo is finally giving the result it should give.

With best regards, Alexander Nozik.

> Hi Alexander,
>
> Le 08/07/2013 14:44, Alexander Nozik a écrit :
> >  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
> >
> http://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates).
> > What i need to know is the final polar angle. Azimuthal angle does not
> > matter.
> > 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 = generator.next() * 2 * Math.PI;
> >         SphericalCoordinates init = new SphericalCoordinates(1, 0,
> > theta+dTheta);
> >         SphericalCoordinates rotate = new SphericalCoordinates(1, 0,
> > theta);
> >         Rotation rot = new Rotation(rotate.getCartesian(), phi);
> >
> >         Vector3D result = rot.applyTo(init.getCartesian());
> >
> >         assert Vector3D.angle(result, init.getCartesian()) == dTheta;
>
> The angle that should be equalt to dTheta is the angle between result
> and rotate.getCartesian(), not the angle between result and
> init.getCartesian(). The latter can take any value between 0 and 2 *
> dTheta.
>
> best regards,
> Luc
>
> >         return Math.acos(result.getZ());
> >
> >     }
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> > For additional commands, e-mail: user-help@commons.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org