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()); > > } > > Thanks in advance. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
