Panda3D
linearRandomForce.I
1 // Filename: linearRandomForce.I
2 // Created by: charles (19Jun00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 ////////////////////////////////////////////////////////////////////
16 // Function : random_unit_vector
17 // Access : Protected
18 // Description : generates a random unit vector
19 ////////////////////////////////////////////////////////////////////
20 INLINE LVector3 LinearRandomForce::
21 random_unit_vector() {
22  PN_stdfloat z, r, theta;
23 
24  z = 1.0 - (2.0 * bounded_rand());
25  r = csqrt(1.0 - (z * z));
26  theta = 2.0 * MathNumbers::pi * bounded_rand();
27 
28  return LVector3(r * ccos(theta), r * csin(theta), z);
29 }
30 
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100