Hello, I have a question for you. I have to initialize a number of 3D vectors, with fixed magnitude (intensity) equal to I, but the sum (in the geometrical sense) of vectors should be null. I prefer to work with angles (azimuth and elevation), but obviously a solution just considering the x-, y- and z-components of the vectors is fine, since thereafter I can make the transformation with cart2sph function.
Thanks a lot to all that could give me a support
No products are associated with this question.
I added a trivial solution. If the number to generate is even, I take couples of vectors. An element of each pair is randomly set, the other in opposite phase. If the number is odd, I do as for even vectors, but excluding three of them, which will be set manually as a null vector according to the rule of parallelogram. Thanks for your help.
Even in just one dimension, it's a non-trivial problem to combine random numbers to have a fixed sum. (The question comes up with some frequency here.) The following doesn't do exactly what you want (I don't believe), but you might be able to bend it to your needs.