Panda3D
linearRandomForce.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file linearRandomForce.I
10  * @author charles
11  * @date 2000-06-19
12  */
13 
14 /**
15  * generates a random unit vector
16  */
17 INLINE LVector3 LinearRandomForce::
18 random_unit_vector() {
19  PN_stdfloat z, r, theta;
20 
21  z = 1.0 - (2.0 * bounded_rand());
22  r = csqrt(1.0 - (z * z));
23  theta = 2.0 * MathNumbers::pi * bounded_rand();
24 
25  return LVector3(r * ccos(theta), r * csin(theta), z);
26 }