]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/sg_random.h
Allow geocentric distance computations to return radians.
[simgear.git] / simgear / math / sg_random.h
index 6d993296106706da6653101aa1e7357c33ad732b..1fed733d3aa5c683d8903177350ab70a0643c126 100644 (file)
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 // Library General Public License for more details.
 //
-// You should have received a copy of the GNU Library General Public
-// License along with this library; if not, write to the
-// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-// Boston, MA  02111-1307, USA.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
@@ -34,6 +33,31 @@ extern "C" {
 #endif                                   
 
 
+#define MT_N 624
+#define MT_M 397
+
+/**
+ * Structure to hold MT algorithm state to easily allow independant
+ * sets of random numbers with different seeds.
+ */
+struct {unsigned int array[MT_N]; int index; } typedef mt;
+
+/**
+ * Initialize a new MT state with a given seed.
+ */
+void mt_init(mt *mt, unsigned int seed);
+
+/**
+ * Generate a new 32-bit random number based on the given MT state.
+ */
+unsigned int mt_rand32( mt *mt);
+
+/**
+ * Generate a new random number between [0.0, 1.0) based 
+ * on the given MT state.
+ */
+double mt_rand(mt *mt);
 /**
  * Seed the random number generater with time() so we don't see the
  * same sequence every time.
@@ -52,7 +76,7 @@ void sg_srandom_time_10();
  * repeatable randomization.
  * @param seed random number generator seed
  */
-void sg_srandom( unsigned int seed );
+void sg_srandom(unsigned int seed );
 
 /**
  * Return a random number between [0.0, 1.0)